]>
code.delx.au - pulseaudio/blob - polyp/xmalloc.c
8 #define MAX_ALLOC_SIZE (1024*1024*20)
16 static void oom(void) {
17 static const char e
[] = "Not enough memory\n";
18 pa_loop_write(2, e
, sizeof(e
)-1);
23 void* pa_xmalloc(size_t size
) {
26 assert(size
< MAX_ALLOC_SIZE
);
28 if (!(p
= malloc(size
)))
34 void* pa_xmalloc0(size_t size
) {
37 assert(size
< MAX_ALLOC_SIZE
);
39 if (!(p
= calloc(1, size
)))
45 void *pa_xrealloc(void *ptr
, size_t size
) {
48 assert(size
< MAX_ALLOC_SIZE
);
50 if (!(p
= realloc(ptr
, size
)))
55 char *pa_xstrdup(const char *s
) {
67 char *pa_xstrndup(const char *s
, size_t l
) {
71 char *r
= strndup(s
, l
);