SphinxBase  5prealpha
listelem_alloc.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /* ====================================================================
3  * Copyright (c) 1999-2004 Carnegie Mellon University. All rights
4  * reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in
15  * the documentation and/or other materials provided with the
16  * distribution.
17  *
18  * This work was supported in part by funding from the Defense Advanced
19  * Research Projects Agency and the National Science Foundation of the
20  * United States of America, and the CMU Sphinx Speech Consortium.
21  *
22  * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
23  * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
24  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
26  * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  *
34  * ====================================================================
35  *
36  */
37 
38 #ifndef __LISTELEM_ALLOC_H__
39 #define __LISTELEM_ALLOC_H__
40 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 #if 0
49 /* Fool Emacs. */
50 }
51 #endif
52 
53 #include <stdlib.h>
54 #ifdef S60
55 #include <types.h>
56 #endif
57 
58 /* Win32/WinCE DLL gunk */
59 #include <sphinxbase/sphinxbase_export.h>
60 #include <sphinxbase/prim_type.h>
61 
66 
70 SPHINXBASE_EXPORT
72 
76 SPHINXBASE_EXPORT
78 
79 
80 SPHINXBASE_EXPORT
81 void *__listelem_malloc__(listelem_alloc_t *le, char *file, int line);
82 
86 #define listelem_malloc(le) __listelem_malloc__((le),__FILE__,__LINE__)
87 
88 SPHINXBASE_EXPORT
89 void *__listelem_malloc_id__(listelem_alloc_t *le, char *file, int line,
90  int32 *out_id);
91 
95 #define listelem_malloc_id(le, oid) __listelem_malloc_id__((le),__FILE__,__LINE__,(oid))
96 
100 SPHINXBASE_EXPORT
101 void *listelem_get_item(listelem_alloc_t *le, int32 id);
102 
106 SPHINXBASE_EXPORT
107 void __listelem_free__(listelem_alloc_t *le, void *elem, char *file, int line);
108 
112 #define listelem_free(le,el) __listelem_free__((le),(el),__FILE__,__LINE__)
113 
117 SPHINXBASE_EXPORT
119 
120 
121 #ifdef __cplusplus
122 }
123 #endif
124 
125 #endif
Basic type definitions used in Sphinx.
Fast linked list allocator.
SPHINXBASE_EXPORT void * listelem_get_item(listelem_alloc_t *le, int32 id)
Retrieve a list element by its identifier.
SPHINXBASE_EXPORT listelem_alloc_t * listelem_alloc_init(size_t elemsize)
Initialize and return a list element allocator.
size_t elemsize
Number of (char *) in element.
SPHINXBASE_EXPORT void listelem_stats(listelem_alloc_t *le)
Print number of allocation, numer of free operation stats.
SPHINXBASE_EXPORT void __listelem_free__(listelem_alloc_t *le, void *elem, char *file, int line)
Free list element of given size.
SPHINXBASE_EXPORT void listelem_alloc_free(listelem_alloc_t *le)
Finalize and release all memory associated with a list element allocator.