malloc.h
Go to the documentation of this file.
00001 #ifndef foomallochfoo
00002 #define foomallochfoo
00003 
00004 /* $Id: malloc.h 1477 2007-05-09 19:45:54Z lennart $ */
00005 
00006 /***
00007   This file is part of avahi.
00008  
00009   avahi is free software; you can redistribute it and/or modify it
00010   under the terms of the GNU Lesser General Public License as
00011   published by the Free Software Foundation; either version 2.1 of the
00012   License, or (at your option) any later version.
00013  
00014   avahi is distributed in the hope that it will be useful, but WITHOUT
00015   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
00016   or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
00017   Public License for more details.
00018  
00019   You should have received a copy of the GNU Lesser General Public
00020   License along with avahi; if not, write to the Free Software
00021   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00022   USA.
00023 ***/
00024 
00027 #include <sys/types.h>
00028 #include <stdarg.h>
00029 #include <limits.h>
00030 #include <assert.h>
00031 
00032 #include <avahi-common/cdecl.h>
00033 #include <avahi-common/gccmacro.h>
00034 
00035 AVAHI_C_DECL_BEGIN
00036 
00038 void *avahi_malloc(size_t size);
00039 
00041 void *avahi_malloc0(size_t size);
00042 
00044 void avahi_free(void *p);
00045 
00047 void *avahi_realloc(void *p, size_t size);
00048 
00050 static inline void* avahi_new_internal(unsigned n, size_t k) {
00051     assert(n < INT_MAX/k);
00052     return avahi_malloc(n*k);
00053 }
00054 
00056 #define avahi_new(type, n) ((type*) avahi_new_internal((n), sizeof(type)))
00057 
00059 static inline void* avahi_new0_internal(unsigned n, size_t k) {
00060     assert(n < INT_MAX/k);
00061     return avahi_malloc0(n*k);
00062 }
00063 
00065 #define avahi_new0(type, n) ((type*) avahi_new0_internal((n), sizeof(type)))
00066 
00068 char *avahi_strdup(const char *s);
00069 
00071 char *avahi_strndup(const char *s, size_t l);
00072 
00074 void *avahi_memdup(const void *s, size_t l);
00075 
00077 typedef struct AvahiAllocator {
00078     void* (*malloc)(size_t size);     
00079     void (*free)(void *p);           
00080     void* (*realloc)(void *p, size_t size);
00081     void* (*calloc)(size_t nmemb, size_t size);   
00082 } AvahiAllocator;
00083 
00086 void avahi_set_allocator(const AvahiAllocator *a);
00087 
00089 char *avahi_strdup_printf(const char *fmt, ... ) AVAHI_GCC_PRINTF_ATTR12;
00090 
00093 char *avahi_strdup_vprintf(const char *fmt, va_list ap);
00096 AVAHI_C_DECL_END
00097 
00098 #endif


pedal_monitor
Author(s): Pedro Mendes
autogenerated on Fri Jun 6 2014 18:37:21