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

Last change on this file since 461 was 277, checked in by rbri, 12 years ago

PDF plugin: Poppler library updated to version 0.12.3

File size: 2.7 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-2009 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#if USE_EXCEPTIONS
32
33class GMemException {
34public:
35  GMemException() {}
36  ~GMemException() {}
37};
38
39#define GMEM_EXCEP throw(GMemException)
40
41#else // USE_EXCEPTIONS
42
43#define GMEM_EXCEP
44
45#endif // USE_EXCEPTIONS
46
47#ifdef __cplusplus
48extern "C" {
49#endif
50
51/*
52 * Same as malloc, but prints error message and exits if malloc()
53 * returns NULL.
54 */
55extern void *gmalloc(size_t size) GMEM_EXCEP;
56extern void *gmalloc_checkoverflow(size_t size) GMEM_EXCEP;
57
58/*
59 * Same as realloc, but prints error message and exits if realloc()
60 * returns NULL.  If <p> is NULL, calls malloc instead of realloc().
61 */
62extern void *grealloc(void *p, size_t size) GMEM_EXCEP;
63extern void *grealloc_checkoverflow(size_t size) GMEM_EXCEP;
64
65/*
66 * These are similar to gmalloc and grealloc, but take an object count
67 * and size.  The result is similar to allocating nObjs * objSize
68 * bytes, but there is an additional error check that the total size
69 * doesn't overflow an int.
70 * The gmallocn_checkoverflow variant returns NULL instead of exiting
71 * the application if a overflow is detected
72 */
73extern void *gmallocn(int nObjs, int objSize) GMEM_EXCEP;
74extern void *gmallocn_checkoverflow(int nObjs, int objSize) GMEM_EXCEP;
75extern void *gmallocn3(int a, int b, int c) GMEM_EXCEP;
76extern void *gmallocn3_checkoverflow(int a, int b, int c) GMEM_EXCEP;
77extern void *greallocn(void *p, int nObjs, int objSize) GMEM_EXCEP;
78extern void *greallocn_checkoverflow(void *p, int nObjs, int objSize) GMEM_EXCEP;
79
80/*
81 * Same as free, but checks for and ignores NULL pointers.
82 */
83extern void gfree(void *p);
84
85#ifdef DEBUG_MEM
86/*
87 * Report on unfreed memory.
88 */
89extern void gMemReport(FILE *f);
90#else
91#define gMemReport(f)
92#endif
93
94/*
95 * Allocate memory and copy a string into it.
96 */
97extern char *copyString(char *s);
98
99/*
100 * Allocate memory and copy a limited-length string to it.
101 */
102extern char *gstrndup(const char *s, size_t n);
103
104#ifdef __cplusplus
105}
106#endif
107
108#endif
Note: See TracBrowser for help on using the repository browser.