beta-0.89.2
[luatex.git] / source / libs / poppler / poppler-src / goo / gmem.h
blob898f33933f961807ce177d067968b8aa1b3c5751
1 /*
2 * gmem.h
4 * Memory routines with out-of-memory checking.
6 * Copyright 1996-2003 Glyph & Cog, LLC
7 */
9 //========================================================================
11 // Modified under the Poppler project - http://poppler.freedesktop.org
13 // All changes made under the Poppler project to this file are licensed
14 // under GPL version 2 or later
16 // Copyright (C) 2005 Takashi Iwai <tiwai@suse.de>
17 // Copyright (C) 2007-2010 Albert Astals Cid <aacid@kde.org>
18 // Copyright (C) 2008 Jonathan Kew <jonathan_kew@sil.org>
20 // To see a description of the changes please see the Changelog file that
21 // came with your tarball or type make ChangeLog if you are building from git
23 //========================================================================
25 #ifndef GMEM_H
26 #define GMEM_H
28 #include <stdio.h>
29 #include "poppler-config.h"
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
36 * Same as malloc, but prints error message and exits if malloc()
37 * returns NULL.
39 extern void *gmalloc(size_t size);
40 extern void *gmalloc_checkoverflow(size_t size);
43 * Same as realloc, but prints error message and exits if realloc()
44 * returns NULL. If <p> is NULL, calls malloc instead of realloc().
46 extern void *grealloc(void *p, size_t size);
47 extern void *grealloc_checkoverflow(size_t size);
50 * These are similar to gmalloc and grealloc, but take an object count
51 * and size. The result is similar to allocating nObjs * objSize
52 * bytes, but there is an additional error check that the total size
53 * doesn't overflow an int.
54 * The gmallocn_checkoverflow variant returns NULL instead of exiting
55 * the application if a overflow is detected
57 extern void *gmallocn(int nObjs, int objSize);
58 extern void *gmallocn_checkoverflow(int nObjs, int objSize);
59 extern void *gmallocn3(int a, int b, int c);
60 extern void *gmallocn3_checkoverflow(int a, int b, int c);
61 extern void *greallocn(void *p, int nObjs, int objSize);
62 extern void *greallocn_checkoverflow(void *p, int nObjs, int objSize);
65 * Same as free, but checks for and ignores NULL pointers.
67 extern void gfree(void *p);
69 #ifdef DEBUG_MEM
71 * Report on unfreed memory.
73 extern void gMemReport(FILE *f);
74 #else
75 #define gMemReport(f)
76 #endif
79 * Allocate memory and copy a string into it.
81 extern char *copyString(const char *s);
84 * Allocate memory and copy a limited-length string to it.
86 extern char *gstrndup(const char *s, size_t n);
88 #ifdef __cplusplus
90 #endif
92 #endif