/usr/include/sphinxbase/ckd_alloc.h is in libsphinxbase-dev 0.8-0ubuntu10.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 | /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */
/* ====================================================================
* Copyright (c) 1999-2004 Carnegie Mellon University. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* This work was supported in part by funding from the Defense Advanced
* Research Projects Agency and the National Science Foundation of the
* United States of America, and the CMU Sphinx Speech Consortium.
*
* THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
* ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
* NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ====================================================================
*
*/
/*
* ckd_alloc.h -- Memory allocation package.
*
* **********************************************
* CMU ARPA Speech Project
*
* Copyright (c) 1999 Carnegie Mellon University.
* ALL RIGHTS RESERVED.
* **********************************************
*
* HISTORY
* $Log: ckd_alloc.h,v $
* Revision 1.10 2005/06/22 02:59:25 arthchan2003
* Added keyword
*
* Revision 1.3 2005/03/30 01:22:48 archan
* Fixed mistakes in last updates. Add
*
*
* 19-Jun-97 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University
* Removed file,line arguments from free functions.
*
* 01-Jan-96 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University
* Created.
*/
/*********************************************************************
*
* $Header: /cvsroot/cmusphinx/sphinx3/src/libutil/ckd_alloc.h,v 1.10 2005/06/22 02:59:25 arthchan2003 Exp $
*
* Carnegie Mellon ARPA Speech Group
*
* Copyright (c) 1994 Carnegie Mellon University.
* All rights reserved.
*
*********************************************************************
*
* file: ckd_alloc.h
*
* traceability:
*
* description:
*
* author:
*
*********************************************************************/
#ifndef _LIBUTIL_CKD_ALLOC_H_
#define _LIBUTIL_CKD_ALLOC_H_
#include <stdlib.h>
#include <setjmp.h>
/* Win32/WinCE DLL gunk */
#include <sphinxbase/sphinxbase_export.h>
#include <sphinxbase/prim_type.h>
/** \file ckd_alloc.h
*\brief Sphinx's memory allocation/deallocation routines.
*
*Implementation of efficient memory allocation deallocation for
*multiple dimensional arrays.
*
*/
#ifdef __cplusplus
extern "C" {
#endif
#if 0
/* Fool Emacs. */
}
#endif
/**
* Control behaviour of the program when allocation fails.
*
* Although your program is probably toast when memory allocation
* fails, it is also probably a good idea to be able to catch these
* errors and alert the user in some way. Either that, or you might
* want the program to call abort() so that you can debug the failed
* code. This function allows you to control that behaviour.
*
* @param env Pointer to a <code>jmp_buf</code> initialized with
* setjmp(), or NULL to remove a previously set jump target.
* @param abort If non-zero, the program will call abort() when
* allocation fails rather than exiting or calling longjmp().
* @return Pointer to a previously set <code>jmp_buf</code>, if any.
*/
jmp_buf *ckd_set_jump(jmp_buf *env, int abort);
/**
* Fail (with a message) according to behaviour specified by ckd_set_jump().
*/
void ckd_fail(char *format, ...);
/*
* The following functions are similar to the malloc family, except
* that they have two additional parameters, caller_file and
* caller_line, for error reporting. All functions print a diagnostic
* message if any error occurs, with any other behaviour determined by
* ckd_set_jump(), above.
*/
SPHINXBASE_EXPORT
void *__ckd_calloc__(size_t n_elem, size_t elem_size,
const char *caller_file, int caller_line);
SPHINXBASE_EXPORT
void *__ckd_malloc__(size_t size,
const char *caller_file, int caller_line);
SPHINXBASE_EXPORT
void *__ckd_realloc__(void *ptr, size_t new_size,
const char *caller_file, int caller_line);
/**
* Like strdup, except that if an error occurs it prints a diagnostic message
* and exits.
*/
SPHINXBASE_EXPORT
char *__ckd_salloc__(const char *origstr,
const char *caller_file, int caller_line);
/**
* Allocate a 2-D array and return ptr to it (ie, ptr to vector of ptrs).
* The data area is allocated in one block so it can also be treated as a 1-D array.
*/
SPHINXBASE_EXPORT
void *__ckd_calloc_2d__(size_t d1, size_t d2, /* In: #elements in the 2 dimensions */
size_t elemsize, /* In: Size (#bytes) of each element */
const char *caller_file, int caller_line); /* In */
/**
* Allocate a 3-D array and return ptr to it.
* The data area is allocated in one block so it can also be treated as a 1-D array.
*/
SPHINXBASE_EXPORT
void *__ckd_calloc_3d__(size_t d1, size_t d2, size_t d3, /* In: #elems in the dims */
size_t elemsize, /* In: Size (#bytes) per element */
const char *caller_file, int caller_line); /* In */
/**
* Allocate a 34D array and return ptr to it.
* The data area is allocated in one block so it can also be treated as a 1-D array.
*/
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);
/**
* Overlay a 3-D array over a previously allocated storage area.
**/
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 s-D array over a previously allocated storage area.
**/
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);
/**
* Test and free a 1-D array
*/
SPHINXBASE_EXPORT
void ckd_free(void *ptr);
/**
* Free a 2-D array (ptr) previously allocated by ckd_calloc_2d
*/
SPHINXBASE_EXPORT
void ckd_free_2d(void *ptr);
/**
* Free a 3-D array (ptr) previously allocated by ckd_calloc_3d
*/
SPHINXBASE_EXPORT
void ckd_free_3d(void *ptr);
/**
* Free a 4-D array (ptr) previously allocated by ckd_calloc_4d
*/
SPHINXBASE_EXPORT
void ckd_free_4d(void *ptr);
/**
* Macros to simplify the use of above functions.
* One should use these, rather than target functions directly.
*/
/**
* Macro for __ckd_calloc__
*/
#define ckd_calloc(n,sz) __ckd_calloc__((n),(sz),__FILE__,__LINE__)
/**
* Macro for __ckd_malloc__
*/
#define ckd_malloc(sz) __ckd_malloc__((sz),__FILE__,__LINE__)
/**
* Macro for __ckd_realloc__
*/
#define ckd_realloc(ptr,sz) __ckd_realloc__(ptr,(sz),__FILE__,__LINE__)
/**
* Macro for __ckd_salloc__
*/
#define ckd_salloc(ptr) __ckd_salloc__(ptr,__FILE__,__LINE__)
/**
* Macro for __ckd_calloc_2d__
*/
#define ckd_calloc_2d(d1,d2,sz) __ckd_calloc_2d__((d1),(d2),(sz),__FILE__,__LINE__)
/**
* Macro for __ckd_calloc_3d__
*/
#define ckd_calloc_3d(d1,d2,d3,sz) __ckd_calloc_3d__((d1),(d2),(d3),(sz),__FILE__,__LINE__)
/**
* Macro for __ckd_calloc_4d__
*/
#define ckd_calloc_4d(d1, d2, d3, d4, s) __ckd_calloc_4d__((d1), (d2), (d3), (d4), (s), __FILE__, __LINE__)
/**
* Macro for __ckd_alloc_2d_ptr__
*/
#define ckd_alloc_2d_ptr(d1, d2, bf, sz) __ckd_alloc_2d_ptr((d1), (d2), (bf), (sz), __FILE__, __LINE__)
/**
* Free only the pointer arrays allocated with ckd_alloc_2d_ptr().
*/
#define ckd_free_2d_ptr(bf) ckd_free(bf)
/**
* Macro for __ckd_alloc_3d_ptr__
*/
#define ckd_alloc_3d_ptr(d1, d2, d3, bf, sz) __ckd_alloc_3d_ptr((d1), (d2), (d3), (bf), (sz), __FILE__, __LINE__)
/**
* Free only the pointer arrays allocated with ckd_alloc_3d_ptr().
*/
#define ckd_free_3d_ptr(bf) ckd_free_2d(bf)
#ifdef __cplusplus
}
#endif
#endif
|