4
* Memory routines with out-of-memory checking.
6
* Copyright 1996-2003 Glyph & Cog, LLC
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
//========================================================================
29
#include "poppler/poppler-config.h"
36
* Same as malloc, but prints error message and exits if malloc()
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);
71
* Report on unfreed memory.
73
extern void gMemReport(FILE *f);
79
* Allocate memory and copy a string into it.
81
extern char *copyString(char *s);
84
* Allocate memory and copy a limited-length string to it.
86
extern char *gstrndup(const char *s, size_t n);