a8ea211eac8331822db3352969826960ffc9a668
[yaz-moved-to-github.git] / include / xmalloc.h
1 /*
2  * Copyright (c) 1995, Index Data.
3  *
4  * Permission to use, copy, modify, distribute, and sell this software and
5  * its documentation, in whole or in part, for any purpose, is hereby granted,
6  * provided that:
7  *
8  * 1. This copyright and permission notice appear in all copies of the
9  * software and its documentation. Notices of copyright or attribution
10  * which appear at the beginning of any file must remain unchanged.
11  *
12  * 2. The names of Index Data or the individual authors may not be used to
13  * endorse or promote products derived from this software without specific
14  * prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS, IMPLIED, OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
18  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
19  * IN NO EVENT SHALL INDEX DATA BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
20  * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES
21  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR
22  * NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
23  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
24  * OF THIS SOFTWARE.
25  *
26  * $Log: xmalloc.h,v $
27  * Revision 1.3  1997-09-01 08:49:54  adam
28  * New windows NT/95 port using MSV5.0. To export DLL functions the
29  * YAZ_EXPORT modifier was added. Defined in yconfig.h.
30  *
31  * Revision 1.2  1997/05/14 06:53:53  adam
32  * C++ support.
33  *
34  * Revision 1.1  1995/11/01 11:55:41  quinn
35  * Added xmalloc.c
36  *
37  * Revision 1.8  1995/10/16  14:03:07  quinn
38  * Changes to support element set names and espec1
39  *
40  * Revision 1.7  1994/10/05  10:15:18  quinn
41  * Added xrealloc.
42  *
43  * Revision 1.6  1994/09/26  16:31:24  adam
44  * Minor changes. xmalloc declares xcalloc now.
45  *
46  * Revision 1.5  1994/09/19  15:46:34  quinn
47  * Added stdlib.h
48  *
49  * Revision 1.4  1994/08/18  08:22:27  adam
50  * Res.h modified. xmalloc now declares xstrdup.
51  *
52  * Revision 1.3  1994/08/17  15:34:15  adam
53  * Initial version of resource manager.
54  *
55  * Revision 1.2  1994/08/17  14:09:48  quinn
56  * Small changes
57  *
58  * Revision 1.1  1994/08/17  13:39:07  adam
59  * Added xmalloc header.
60  *
61  * Revision 1.1  1994/08/16  16:16:02  adam
62  * bfile header created.
63  *
64  */
65
66 #ifndef XMALLOC_H
67 #define XMALLOC_H
68
69 #include <sys/types.h>
70 #include <stdlib.h>
71
72 #include <yconfig.h>
73
74 #ifdef __cplusplus
75 extern "C" {
76 #endif
77
78 YAZ_EXPORT void *xrealloc_f (void *o, size_t size, char *file, int line);
79 YAZ_EXPORT void *xmalloc_f (size_t size, char *file, int line);
80 YAZ_EXPORT void *xcalloc_f (size_t nmemb, size_t size, char *file, int line);
81 YAZ_EXPORT char *xstrdup_f (const char *, char *file, int line);
82 YAZ_EXPORT void xfree_f (void *p, char *file, int line);
83
84 #define xrealloc(o, x) xrealloc_f(o, x, __FILE__, __LINE__)
85 #define xmalloc(x) xmalloc_f(x, __FILE__, __LINE__)
86 #define xcalloc(x,y) xcalloc_f(x,y, __FILE__, __LINE__)
87 #define xfree(x) xfree_f(x, __FILE__, __LINE__)
88 #define xstrdup(s) xstrdup_f(s, __FILE__, __LINE__)
89
90 #ifdef __cplusplus
91 }
92 #endif
93
94 #endif