~diwic/ubuntu/lucid/pulseaudio/bugfixes

« back to all changes in this revision

Viewing changes to src/pulse/xmalloc.h

  • Committer: Bazaar Package Importer
  • Author(s): Luke Yelavich
  • Date: 2008-11-04 15:46:00 UTC
  • mfrom: (1.2.1 upstream) (1.1.6 lenny)
  • Revision ID: james.westby@ubuntu.com-20081104154600-hlzknpcazaam0nxm
Tags: 0.9.13-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Don't build against, and create jack package. Jack is not in main.
  - Remove --disable-per-user-esound-socket from configure flags, as we still
    want per user esound sockets.
  - Remove stop links from rc0 and rc6.
  - Change default resample algorithm and bubffer size.
  - Add alsa configuration files to route alsa applications via pulseaudio.
  - Move libasound2-plugins from Recommends to Depends.
* debian/pulseaudio.preinst: When upgrading from intrepid, remove
  /etc/X11/Xsession.d/70pulseaudio, as this was used to minimize a race
  condition when starting GNOME in intrepid. This race should not exist in
  jaunty once libcanberra is built to use pulseaudio as a backend.
* Do not spawn a pulseaudio server if clients fail to find a running server.
* Remove explicit version dependency for libspeex-dev to allow the package
  to be built for now.
* Regenerate autotools files to work with Ubuntu's newer libtool/libltdl.
* debian/control: libpulsecore5 -> libpulsecore8 to match the library
  soname.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#ifndef foomemoryhfoo
2
2
#define foomemoryhfoo
3
3
 
4
 
/* $Id: xmalloc.h 1971 2007-10-28 19:13:50Z lennart $ */
5
 
 
6
4
/***
7
5
  This file is part of PulseAudio.
8
6
 
28
26
#include <stdlib.h>
29
27
#include <limits.h>
30
28
#include <assert.h>
 
29
 
31
30
#include <pulse/cdecl.h>
 
31
#include <pulse/gccmacro.h>
32
32
 
33
33
/** \file
34
34
 * Memory allocation functions.
37
37
PA_C_DECL_BEGIN
38
38
 
39
39
/** Allocate the specified number of bytes, just like malloc() does. However, in case of OOM, terminate */
40
 
void* pa_xmalloc(size_t l);
 
40
void* pa_xmalloc(size_t l) PA_GCC_MALLOC PA_GCC_ALLOC_SIZE(1);
41
41
 
42
42
/** Same as pa_xmalloc(), but initialize allocated memory to 0 */
43
 
void *pa_xmalloc0(size_t l);
 
43
void *pa_xmalloc0(size_t l) PA_GCC_MALLOC PA_GCC_ALLOC_SIZE(1);
44
44
 
45
45
/**  The combination of pa_xmalloc() and realloc() */
46
 
void *pa_xrealloc(void *ptr, size_t size);
 
46
void *pa_xrealloc(void *ptr, size_t size) PA_GCC_ALLOC_SIZE(2);
47
47
 
48
48
/** Free allocated memory */
49
49
void pa_xfree(void *p);
50
50
 
51
51
/** Duplicate the specified string, allocating memory with pa_xmalloc() */
52
 
char *pa_xstrdup(const char *s);
 
52
char *pa_xstrdup(const char *s) PA_GCC_MALLOC;
53
53
 
54
54
/** Duplicate the specified string, but truncate after l characters */
55
 
char *pa_xstrndup(const char *s, size_t l);
 
55
char *pa_xstrndup(const char *s, size_t l) PA_GCC_MALLOC;
56
56
 
57
57
/** Duplicate the specified memory block */
58
 
void* pa_xmemdup(const void *p, size_t l);
 
58
void* pa_xmemdup(const void *p, size_t l) PA_GCC_MALLOC PA_GCC_ALLOC_SIZE(2);
59
59
 
60
60
/** Internal helper for pa_xnew() */
61
 
static inline void* pa_xnew_internal(unsigned n, size_t k) {
 
61
static void* _pa_xnew_internal(size_t n, size_t k) PA_GCC_MALLOC PA_GCC_ALLOC_SIZE2(1,2);
 
62
 
 
63
static inline void* _pa_xnew_internal(size_t n, size_t k) {
62
64
    assert(n < INT_MAX/k);
63
65
    return pa_xmalloc(n*k);
64
66
}
65
67
 
66
68
/** Allocate n new structures of the specified type. */
67
 
#define pa_xnew(type, n) ((type*) pa_xnew_internal((n), sizeof(type)))
 
69
#define pa_xnew(type, n) ((type*) _pa_xnew_internal((n), sizeof(type)))
68
70
 
69
71
/** Internal helper for pa_xnew0() */
70
 
static inline void* pa_xnew0_internal(unsigned n, size_t k) {
 
72
static void* _pa_xnew0_internal(size_t n, size_t k) PA_GCC_MALLOC PA_GCC_ALLOC_SIZE2(1,2);
 
73
 
 
74
static inline void* _pa_xnew0_internal(size_t n, size_t k) {
71
75
    assert(n < INT_MAX/k);
72
76
    return pa_xmalloc0(n*k);
73
77
}
74
78
 
75
79
/** Same as pa_xnew() but set the memory to zero */
76
 
#define pa_xnew0(type, n) ((type*) pa_xnew0_internal((n), sizeof(type)))
 
80
#define pa_xnew0(type, n) ((type*) _pa_xnew0_internal((n), sizeof(type)))
77
81
 
78
82
/** Internal helper for pa_xnew0() */
79
 
static inline void* pa_xnewdup_internal(const void *p, unsigned n, size_t k) {
 
83
static void* _pa_xnewdup_internal(const void *p, size_t n, size_t k) PA_GCC_MALLOC PA_GCC_ALLOC_SIZE2(2,3);
 
84
 
 
85
static inline void* _pa_xnewdup_internal(const void *p, size_t n, size_t k) {
80
86
    assert(n < INT_MAX/k);
81
87
    return pa_xmemdup(p, n*k);
82
88
}
83
89
 
84
90
/** Same as pa_xnew() but set the memory to zero */
85
 
#define pa_xnewdup(type, p, n) ((type*) pa_xnewdup_internal((p), (n), sizeof(type)))
 
91
#define pa_xnewdup(type, p, n) ((type*) _pa_xnewdup_internal((p), (n), sizeof(type)))
86
92
 
87
93
PA_C_DECL_END
88
94