softcount: tolerate zero ngrams
[vspell.git] / libvspell / lm / CM_macros.h
blobd2a64fac5d57a93701dff70e9b31eca134fce8ae
1 /* ====================================================================
2 * Copyright (c) 1999-2001 Carnegie Mellon University. All rights
3 * reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
18 * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
19 * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
22 * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 * ====================================================================
34 /* CM_macros.h
36 * **********************************************
37 * CMU ARPA Speech Project
39 * Copyright (c) 1989 Carnegie Mellon University.
40 * ALL RIGHTS RESERVED.
41 * **********************************************
43 *------------------------------------------------------------*
44 * DESCRIPTION
45 * CMPSL macros to make error handling a little easier.
46 *------------------------------------------------------------*
47 * HISTORY
49 * $Log: CM_macros.h,v $
50 * Revision 1.5 2004/12/10 16:48:55 rkm
51 * Added continuous density acoustic model handling
54 * Spring 89, Fil Alleva (faa) Carnegie Mellon
55 * Created
59 #ifndef _CM_MACROS_H_
60 #define _CM_MACROS_H_
62 /* CM_fopen
63 *------------------------------------------------------------*
64 */
65 #define CM_fopen(name,mode) _CM_fopen((name),(mode),__FILE__,__LINE__)
67 /* CM_fopenp
68 *------------------------------------------------------------*
69 */
70 #define CM_fopenp(dirl,name,mode) _CM_fopenp((dirl),(name),(mode),__FILE__,__LINE__)
73 /* CM_fread
74 *------------------------------------------------------------*
75 */
76 #define CM_fread(ptr,size,cnt,stream) \
77 { \
78 char mesg[1024]; \
79 if (fread(ptr,size,cnt,stream) != cnt) { \
80 sprintf (mesg, "%s(%d): fread failed", \
81 __FILE__, __LINE__); \
82 perror (mesg); \
83 exit (-1); \
84 } \
88 /* CM_calloc
89 *------------------------------------------------------------*
90 */
91 #define CM_calloc(cnt,size) _CM_calloc((cnt),(size),__FILE__,__LINE__)
94 /* CM_2dcalloc
95 *------------------------------------------------------------*
96 */
97 #define CM_2dcalloc(rcnt,ccnt,size) _CM_2dcalloc((rcnt),(ccnt),(size),__FILE__,__LINE__)
100 /* CM_3dcalloc
101 *------------------------------------------------------------*
103 #define CM_3dcalloc(lcnt,rcnt,ccnt,size) \
104 _CM_3dcalloc((lcnt),(rcnt),(ccnt),(size),__FILE__,__LINE__)
107 /* CM_recalloc
108 *------------------------------------------------------------*
110 #define CM_recalloc(ptr,cnt,size) _CM_recalloc((ptr),(cnt),(size),__FILE__,__LINE__)
113 extern FILE *_CM_fopen(char const *file, char const *mode,
114 char const *srcfile, int32 srcline);
115 extern FILE *_CM_fopenp(char const *dirl, char const *file,
116 char const *mode, char const *srcfile,
117 int32 srcline);
118 extern void *_CM_calloc(int32 cnt, int32 size, char const *file, int32 line);
119 extern void *_CM_2dcalloc(int32 rcnt, int32 ccnt, int32 size, char const *srcfile, int32 srcline);
120 extern void *_CM_3dcalloc(int32 lcnt, int32 rcnt, int32 ccnt, int32 size,
121 char const *srcfile, int32 srcline);
122 extern void *_CM_recalloc(void *ptr, int32 cnt, int32 size,
123 char const *srcfile, int32 srcline);
125 #endif /* _CM_MACROS_H_ */