Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef SU_ALLOC_H
00026 #define SU_ALLOC_H
00027
00037 #ifndef SU_TYPES_H
00038 #include <sofia-sip/su_types.h>
00039 #endif
00040
00041 #include <stdarg.h>
00042
00043 SOFIA_BEGIN_DECLS
00044
00045 #ifndef SU_HOME_T
00046 #define SU_HOME_T struct su_home_s
00047 #endif
00048
00050 typedef SU_HOME_T su_home_t;
00051 typedef struct su_block_s su_block_t;
00052
00054 typedef struct su_alock su_alock_t;
00055
00057 struct su_home_s {
00058 int suh_size;
00059 su_block_t *suh_blocks;
00060 su_alock_t *suh_lock;
00061 };
00062
00063 #define SU_HOME_INIT(obj) { 0, NULL, NULL }
00064
00065 SU_DLL void *su_home_new(isize_t size)
00066 __attribute__((__malloc__));
00067 SU_DLL void *su_home_ref(su_home_t const *);
00068 SU_DLL int su_home_unref(su_home_t *);
00069
00070 SU_DLL size_t su_home_refcount(su_home_t *home);
00071
00072 SU_DLL int su_home_destructor(su_home_t *, void (*)(void *));
00073
00074 SU_DLL int su_home_desctructor(su_home_t *, void (*)(void *));
00075 #ifndef su_home_desctructor
00076
00077 #define su_home_desctructor(home, destructor) \
00078 su_home_destructor((home), (destructor))
00079 #endif
00080
00081 SU_DLL void *su_home_clone(su_home_t *parent, isize_t size)
00082 __attribute__((__malloc__));
00083
00084 SU_DLL int su_home_init(su_home_t *h);
00085
00086 SU_DLL void su_home_deinit(su_home_t *h);
00087
00088 SU_DLL void su_home_preload(su_home_t *h, isize_t n, isize_t size);
00089
00090 SU_DLL su_home_t *su_home_auto(void *area, isize_t size);
00091
00092 #define SU_HOME_AUTO_SIZE(n) \
00093 (((n) + ((sizeof(su_home_t) + 7) & (size_t)~8) + \
00094 ((3 * sizeof (void *) + 4 * sizeof(unsigned) + \
00095 7 * (sizeof (long) + sizeof(void *)) + 7) & (size_t)~8)) \
00096 / sizeof(su_home_t))
00097
00098 SU_DLL int su_home_move(su_home_t *dst, su_home_t *src);
00099
00100 SU_DLL int su_home_threadsafe(su_home_t *home);
00101
00102 SU_DLL int su_home_has_parent(su_home_t const *home);
00103
00104 SU_DLL su_home_t *su_home_parent(su_home_t const *home);
00105
00106 SU_DLL void su_home_check(su_home_t const *home);
00107
00108 SU_DLL int su_home_check_alloc(su_home_t const *home, void const *data);
00109
00110 SU_DLL int su_home_mutex_lock(su_home_t *home);
00111
00112 SU_DLL int su_home_mutex_unlock(su_home_t *home);
00113
00114 SU_DLL int su_home_lock(su_home_t *home);
00115 SU_DLL int su_home_trylock(su_home_t *home);
00116 SU_DLL int su_home_unlock(su_home_t *home);
00117
00118 SU_DLL void *su_alloc(su_home_t *h, isize_t size)
00119 __attribute__((__malloc__));
00120 SU_DLL void *su_zalloc(su_home_t *h, isize_t size)
00121 __attribute__((__malloc__));
00122 SU_DLL void *su_salloc(su_home_t *h, isize_t size)
00123 __attribute__((__malloc__));
00124 SU_DLL void *su_realloc(su_home_t *h, void *data, isize_t size)
00125 __attribute__((__malloc__));
00126 SU_DLL int su_in_home(su_home_t *h, void const *data);
00127
00128 SU_DLL char *su_strdup(su_home_t *home, char const *s)
00129 __attribute__((__malloc__));
00130 SU_DLL char *su_strcat(su_home_t *home, char const *s1, char const *s2)
00131 __attribute__((__malloc__));
00132 SU_DLL char *su_strndup(su_home_t *home, char const *s, isize_t n)
00133 __attribute__((__malloc__));
00134
00135 SU_DLL char *su_strcat_all(su_home_t *home, ...)
00136 __attribute__((__malloc__));
00137
00138 SU_DLL char *su_sprintf(su_home_t *home, char const *fmt, ...)
00139 __attribute__ ((__malloc__, __format__ (printf, 2, 3)));
00140
00141 SU_DLL char *su_vsprintf(su_home_t *home, char const *fmt, va_list ap)
00142 __attribute__((__malloc__));
00143
00144
00145 SU_DLL void su_free(su_home_t *h, void *);
00146
00148 SU_DLL int su_home_is_threadsafe(su_home_t const *home);
00149
00150
00151
00152
00153 SU_DLL su_home_t *su_home_create(void)
00154 __attribute__((__malloc__));
00155 SU_DLL void su_home_destroy(su_home_t *h);
00156
00157 #define su_home_zap(h) su_home_unref((h))
00158
00159 SOFIA_END_DECLS
00160
00161 #endif