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_CONFIG_H
00038 #include <sofia-sip/su_config.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 }
00064
00065 SU_DLL void *su_home_new(int 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 int su_home_desctructor(su_home_t *, void (*)(void *));
00071
00072 SU_DLL void *su_home_clone(su_home_t *parent, int size)
00073 __attribute__((__malloc__));
00074
00075 SU_DLL int su_home_init(su_home_t *h);
00076
00077 SU_DLL void su_home_deinit(su_home_t *h);
00078
00079 SU_DLL void su_home_preload(su_home_t *h, int n, int size);
00080
00081 SU_DLL su_home_t *su_home_auto(void *area, int size);
00082
00083 #define SU_HOME_AUTO_SIZE(n) \
00084 (((n) + ((sizeof(su_home_t) + 7) & ~8) + \
00085 ((3 * sizeof (void *) + 4 * sizeof(unsigned) + \
00086 7 * (sizeof (long) + sizeof(void *)) + 7) & ~8)) \
00087 / sizeof(su_home_t))
00088
00089 SU_DLL int su_home_move(su_home_t *dst, su_home_t *src);
00090
00091 SU_DLL int su_home_threadsafe(su_home_t *home);
00092
00093 SU_DLL int su_home_has_parent(su_home_t const *home);
00094
00095 SU_DLL void su_home_check(su_home_t const *home);
00096
00097 SU_DLL int su_home_mutex_lock(su_home_t *home);
00098
00099 SU_DLL int su_home_mutex_unlock(su_home_t *home);
00100
00101 SU_DLL void *su_alloc(su_home_t *h, int size)
00102 __attribute__((__malloc__));
00103 SU_DLL void *su_zalloc(su_home_t *h, int size)
00104 __attribute__((__malloc__));
00105 SU_DLL void *su_salloc(su_home_t *h, int size)
00106 __attribute__((__malloc__));
00107 SU_DLL void *su_realloc(su_home_t *h, void *data, int size)
00108 __attribute__((__malloc__));
00109
00110 SU_DLL char *su_strdup(su_home_t *home, char const *s)
00111 __attribute__((__malloc__));
00112 SU_DLL char *su_strcat(su_home_t *home, char const *s1, char const *s2)
00113 __attribute__((__malloc__));
00114 SU_DLL char *su_strndup(su_home_t *home, char const *s, int n)
00115 __attribute__((__malloc__));
00116
00117 SU_DLL char *su_strcat_all(su_home_t *home, ...)
00118 __attribute__((__malloc__));
00119
00120 SU_DLL char *su_sprintf(su_home_t *home, char const *fmt, ...)
00121 __attribute__ ((__malloc__, __format__ (printf, 2, 3)));
00122
00123 SU_DLL char *su_vsprintf(su_home_t *home, char const *fmt, va_list ap)
00124 __attribute__((__malloc__));
00125
00126
00127 SU_DLL void su_free(su_home_t *h, void *);
00128
00130 SU_DLL int su_home_is_threadsafe(su_home_t const *home);
00131
00132
00133
00134
00135 SU_DLL su_home_t *su_home_create(void)
00136 __attribute__((__malloc__));
00137 SU_DLL void su_home_destroy(su_home_t *h);
00138
00139 #define su_home_zap(h) su_home_unref((h))
00140
00141 SOFIA_END_DECLS
00142
00143 #endif