123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- #ifndef foomallochfoo
- #define foomallochfoo
- #include <sys/types.h>
- #include <stdarg.h>
- #include <limits.h>
- #include <assert.h>
- #include <avahi-common/cdecl.h>
- #include <avahi-common/gccmacro.h>
- AVAHI_C_DECL_BEGIN
- void *avahi_malloc(size_t size) AVAHI_GCC_ALLOC_SIZE(1);
- void *avahi_malloc0(size_t size) AVAHI_GCC_ALLOC_SIZE(1);
- void avahi_free(void *p);
- void *avahi_realloc(void *p, size_t size) AVAHI_GCC_ALLOC_SIZE(2);
- static inline void* AVAHI_GCC_ALLOC_SIZE2(1,2) avahi_new_internal(unsigned n, size_t k) {
- assert(n < INT_MAX/k);
- return avahi_malloc(n*k);
- }
- #define avahi_new(type, n) ((type*) avahi_new_internal((n), sizeof(type)))
- static inline void* AVAHI_GCC_ALLOC_SIZE2(1,2) avahi_new0_internal(unsigned n, size_t k) {
- assert(n < INT_MAX/k);
- return avahi_malloc0(n*k);
- }
- #define avahi_new0(type, n) ((type*) avahi_new0_internal((n), sizeof(type)))
- char *avahi_strdup(const char *s);
- char *avahi_strndup(const char *s, size_t l);
- void *avahi_memdup(const void *s, size_t l) AVAHI_GCC_ALLOC_SIZE(2);
- typedef struct AvahiAllocator {
- void* (*malloc)(size_t size) AVAHI_GCC_ALLOC_SIZE(1);
- void (*free)(void *p);
- void* (*realloc)(void *p, size_t size) AVAHI_GCC_ALLOC_SIZE(2);
- void* (*calloc)(size_t nmemb, size_t size) AVAHI_GCC_ALLOC_SIZE2(1,2);
- } AvahiAllocator;
- void avahi_set_allocator(const AvahiAllocator *a);
- char *avahi_strdup_printf(const char *fmt, ... ) AVAHI_GCC_PRINTF_ATTR12;
- char *avahi_strdup_vprintf(const char *fmt, va_list ap);
- AVAHI_C_DECL_END
- #endif
|