source: trunk/poppler/mypoppler/goo/gmem.h @ 470

Last change on this file since 470 was 470, checked in by Silvan Scherrer, 11 years ago

poppler, jpeg, freetype lib updates

File size: 2.4 KB
Line 
1/*
2 * gmem.h
3 *
4 * Memory routines with out-of-memory checking.
5 *
6 * Copyright 1996-2003 Glyph & Cog, LLC
7 */
8
9//========================================================================
10//
11// Modified under the Poppler project - http://poppler.freedesktop.org
12//
13// All changes made under the Poppler project to this file are licensed
14// under GPL version 2 or later
15//
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>
19//
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
22//
23//========================================================================
24
25#ifndef GMEM_H
26#define GMEM_H
27
28#include <stdio.h>
29#include "poppler/poppler-config.h"
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
35/*
36 * Same as malloc, but prints error message and exits if malloc()
37 * returns NULL.
38 */
39extern void *gmalloc(size_t size);
40extern void *gmalloc_checkoverflow(size_t size);
41
42/*
43 * Same as realloc, but prints error message and exits if realloc()
44 * returns NULL.  If <p> is NULL, calls malloc instead of realloc().
45 */
46extern void *grealloc(void *p, size_t size);
47extern void *grealloc_checkoverflow(size_t size);
48
49/*
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
56 */
57extern void *gmallocn(int nObjs, int objSize);
58extern void *gmallocn_checkoverflow(int nObjs, int objSize);
59extern void *gmallocn3(int a, int b, int c);
60extern void *gmallocn3_checkoverflow(int a, int b, int c);
61extern void *greallocn(void *p, int nObjs, int objSize);
62extern void *greallocn_checkoverflow(void *p, int nObjs, int objSize);
63
64/*
65 * Same as free, but checks for and ignores NULL pointers.
66 */
67extern void gfree(void *p);
68
69#ifdef DEBUG_MEM
70/*
71 * Report on unfreed memory.
72 */
73extern void gMemReport(FILE *f);
74#else
75#define gMemReport(f)
76#endif
77
78/*
79 * Allocate memory and copy a string into it.
80 */
81extern char *copyString(char *s);
82
83/*
84 * Allocate memory and copy a limited-length string to it.
85 */
86extern char *gstrndup(const char *s, size_t n);
87
88#ifdef __cplusplus
89}
90#endif
91
92#endif
Note: See TracBrowser for help on using the repository browser.