86#ifndef _LIBUTIL_CKD_ALLOC_H_
87#define _LIBUTIL_CKD_ALLOC_H_
93#include <sphinxbase/sphinxbase_export.h>
143void *__ckd_calloc__(
size_t n_elem,
size_t elem_size,
144 const char *caller_file,
int caller_line);
147void *__ckd_malloc__(
size_t size,
148 const char *caller_file,
int caller_line);
151void *__ckd_realloc__(
void *ptr,
size_t new_size,
152 const char *caller_file,
int caller_line);
160 const char *caller_file,
int caller_line);
169 const char *caller_file,
int caller_line);
178 const char *caller_file,
int caller_line);
248#define ckd_calloc(n,sz) __ckd_calloc__((n),(sz),__FILE__,__LINE__)
253#define ckd_malloc(sz) __ckd_malloc__((sz),__FILE__,__LINE__)
258#define ckd_realloc(ptr,sz) __ckd_realloc__(ptr,(sz),__FILE__,__LINE__)
264#define ckd_salloc(ptr) __ckd_salloc__(ptr,__FILE__,__LINE__)
270#define ckd_calloc_2d(d1,d2,sz) __ckd_calloc_2d__((d1),(d2),(sz),__FILE__,__LINE__)
276#define ckd_calloc_3d(d1,d2,d3,sz) __ckd_calloc_3d__((d1),(d2),(d3),(sz),__FILE__,__LINE__)
281#define ckd_calloc_4d(d1, d2, d3, d4, s) __ckd_calloc_4d__((d1), (d2), (d3), (d4), (s), __FILE__, __LINE__)
287#define ckd_alloc_2d_ptr(d1, d2, bf, sz) __ckd_alloc_2d_ptr((d1), (d2), (bf), (sz), __FILE__, __LINE__)
292#define ckd_free_2d_ptr(bf) ckd_free(bf)
298#define ckd_alloc_3d_ptr(d1, d2, d3, bf, sz) __ckd_alloc_3d_ptr((d1), (d2), (d3), (bf), (sz), __FILE__, __LINE__)
303#define ckd_free_3d_ptr(bf) ckd_free_2d(bf)
SPHINXBASE_EXPORT void * __ckd_calloc_2d__(size_t d1, size_t d2, size_t elemsize, const char *caller_file, int caller_line)
Allocate a 2-D array and return ptr to it (ie, ptr to vector of ptrs).
jmp_buf * ckd_set_jump(jmp_buf *env, int abort)
Control behaviour of the program when allocation fails.
SPHINXBASE_EXPORT void ckd_free_4d(void *ptr)
Free a 4-D array (ptr) previously allocated by ckd_calloc_4d.
SPHINXBASE_EXPORT void ckd_free(void *ptr)
Test and free a 1-D array.
SPHINXBASE_EXPORT void ckd_free_3d(void *ptr)
Free a 3-D array (ptr) previously allocated by ckd_calloc_3d.
SPHINXBASE_EXPORT char * __ckd_salloc__(const char *origstr, const char *caller_file, int caller_line)
Like strdup, except that if an error occurs it prints a diagnostic message and exits.
SPHINXBASE_EXPORT void * __ckd_calloc_3d__(size_t d1, size_t d2, size_t d3, size_t elemsize, const char *caller_file, int caller_line)
Allocate a 3-D array and return ptr to it.
SPHINXBASE_EXPORT void ckd_free_2d(void *ptr)
Free a 2-D array (ptr) previously allocated by ckd_calloc_2d.
SPHINXBASE_EXPORT void * __ckd_alloc_3d_ptr(size_t d1, size_t d2, size_t d3, void *store, size_t elem_size, char *caller_file, int caller_line)
Overlay a 3-D array over a previously allocated storage area.
void ckd_fail(char *format,...)
Fail (with a message) according to behaviour specified by ckd_set_jump().
SPHINXBASE_EXPORT void * __ckd_alloc_2d_ptr(size_t d1, size_t d2, void *store, size_t elem_size, char *caller_file, int caller_line)
Overlay a s-D array over a previously allocated storage area.
SPHINXBASE_EXPORT void **** __ckd_calloc_4d__(size_t d1, size_t d2, size_t d3, size_t d4, size_t elem_size, char *caller_file, int caller_line)
Allocate a 34D array and return ptr to it.
Basic type definitions used in Sphinx.