diff options
author | Albert Astals Cid <aacid@kde.org> | 2010-07-19 16:31:54 +0100 |
---|---|---|
committer | Albert Astals Cid <aacid@kde.org> | 2010-07-19 16:31:54 +0100 |
commit | 49ffb46db3118db874d2d9830bb034762d625c61 (patch) | |
tree | b3fa2730a8d72ff1e19ad39221838b5851737356 | |
parent | dd2e9399868e3dbf2fa4ede050f8d74d29ebbbb4 (diff) |
Remove exception support
We don't use it and don't even support it properly
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | config.h.cmake | 3 | ||||
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | goo/gmem.cc | 56 | ||||
-rw-r--r-- | goo/gmem.h | 38 | ||||
-rw-r--r-- | poppler/poppler-config.h.cmake | 5 | ||||
-rw-r--r-- | poppler/poppler-config.h.in | 5 |
7 files changed, 27 insertions, 85 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index a11d96c2..916a7805 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,7 +31,6 @@ option(ENABLE_LIBOPENJPEG "Use libopenjpeg for JPX streams." ON) option(ENABLE_LCMS "Use liblcms for color management." ON) option(ENABLE_LIBCURL "Build libcurl based HTTP support." OFF) option(ENABLE_ZLIB "Build with zlib (not totally safe)." OFF) -option(USE_EXCEPTIONS "Throw exceptions to deal with not enough memory and similar problems." OFF) option(USE_FIXEDPOINT "Use fixed point arithmetic in the Splash backend" OFF) option(USE_FLOAT "Use single precision arithmetic in the Splash backend" OFF) if(WIN32) diff --git a/config.h.cmake b/config.h.cmake index 0879aeb5..123288a9 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -171,9 +171,6 @@ /* Defines if use cms */ #cmakedefine USE_CMS 1 -/* Throw exceptions to deal with not enough memory and similar problems */ -#cmakedefine USE_EXCEPTIONS 1 - /* Use fixed point arithmetic in the Splash backend */ #cmakedefine USE_FIXEDPOINT 1 diff --git a/configure.ac b/configure.ac index 060028f8..a1a5d025 100644 --- a/configure.ac +++ b/configure.ac @@ -108,10 +108,6 @@ dnl ##### Checks for header files. AC_PATH_XTRA AC_HEADER_DIRENT -AC_ARG_ENABLE(exceptions, - [ --enable-exceptions use C++ exceptions], - AC_DEFINE([USE_EXCEPTIONS], [1], [Throw exceptions to deal with not enough memory and similar problems])) - dnl ##### Switch over to C++. This will make the checks below a little dnl ##### bit stricter (requiring function prototypes in include files). dnl ##### (99% of xpdf is written in C++.) diff --git a/goo/gmem.cc b/goo/gmem.cc index af3e19ef..ff0703be 100644 --- a/goo/gmem.cc +++ b/goo/gmem.cc @@ -14,7 +14,7 @@ // under GPL version 2 or later // // Copyright (C) 2005 Takashi Iwai <tiwai@suse.de> -// Copyright (C) 2007-2009 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2007-2010 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2008 Jonathan Kew <jonathan_kew@sil.org> // // To see a description of the changes please see the Changelog file that @@ -63,7 +63,7 @@ static int gMemInUse = 0; #endif /* DEBUG_MEM */ -inline static void *gmalloc(size_t size, bool checkoverflow) GMEM_EXCEP { +inline static void *gmalloc(size_t size, bool checkoverflow) { #ifdef DEBUG_MEM int size1; char *mem; @@ -76,13 +76,9 @@ inline static void *gmalloc(size_t size, bool checkoverflow) GMEM_EXCEP { } size1 = gMemDataSize(size); if (!(mem = (char *)malloc(size1 + gMemHdrSize + gMemTrlSize))) { -#if USE_EXCEPTIONS - throw GMemException(); -#else fprintf(stderr, "Out of memory\n"); if (checkoverflow) return NULL; else exit(1); -#endif } hdr = (GMemHdr *)mem; data = (void *)(mem + gMemHdrSize); @@ -112,27 +108,23 @@ inline static void *gmalloc(size_t size, bool checkoverflow) GMEM_EXCEP { return NULL; } if (!(p = malloc(size))) { -#if USE_EXCEPTIONS - throw GMemException(); -#else fprintf(stderr, "Out of memory\n"); if (checkoverflow) return NULL; else exit(1); -#endif } return p; #endif } -void *gmalloc(size_t size) GMEM_EXCEP { +void *gmalloc(size_t size) { return gmalloc(size, false); } -void *gmalloc_checkoverflow(size_t size) GMEM_EXCEP { +void *gmalloc_checkoverflow(size_t size) { return gmalloc(size, true); } -inline static void *grealloc(void *p, size_t size, bool checkoverflow) GMEM_EXCEP { +inline static void *grealloc(void *p, size_t size, bool checkoverflow) { #ifdef DEBUG_MEM GMemHdr *hdr; void *q; @@ -169,27 +161,23 @@ inline static void *grealloc(void *p, size_t size, bool checkoverflow) GMEM_EXCE q = malloc(size); } if (!q) { -#if USE_EXCEPTIONS - throw GMemException(); -#else fprintf(stderr, "Out of memory\n"); if (checkoverflow) return NULL; else exit(1); -#endif } return q; #endif } -void *grealloc(void *p, size_t size) GMEM_EXCEP { +void *grealloc(void *p, size_t size) { return grealloc(p, size, false); } -void *grealloc_checkoverflow(void *p, size_t size) GMEM_EXCEP { +void *grealloc_checkoverflow(void *p, size_t size) { return grealloc(p, size, true); } -inline static void *gmallocn(int nObjs, int objSize, bool checkoverflow) GMEM_EXCEP { +inline static void *gmallocn(int nObjs, int objSize, bool checkoverflow) { int n; if (nObjs == 0) { @@ -197,48 +185,40 @@ inline static void *gmallocn(int nObjs, int objSize, bool checkoverflow) GMEM_EX } n = nObjs * objSize; if (objSize <= 0 || nObjs < 0 || nObjs >= INT_MAX / objSize) { -#if USE_EXCEPTIONS - throw GMemException(); -#else fprintf(stderr, "Bogus memory allocation size\n"); if (checkoverflow) return NULL; else exit(1); -#endif } return gmalloc(n, checkoverflow); } -void *gmallocn(int nObjs, int objSize) GMEM_EXCEP { +void *gmallocn(int nObjs, int objSize) { return gmallocn(nObjs, objSize, false); } -void *gmallocn_checkoverflow(int nObjs, int objSize) GMEM_EXCEP { +void *gmallocn_checkoverflow(int nObjs, int objSize) { return gmallocn(nObjs, objSize, true); } -inline static void *gmallocn3(int a, int b, int c, bool checkoverflow) GMEM_EXCEP { +inline static void *gmallocn3(int a, int b, int c, bool checkoverflow) { int n = a * b; if (b <= 0 || a < 0 || a >= INT_MAX / b) { -#if USE_EXCEPTIONS - throw GMemException(); -#else fprintf(stderr, "Bogus memory allocation size\n"); if (checkoverflow) return NULL; else exit(1); -#endif } return gmallocn(n, c, checkoverflow); } -void *gmallocn3(int a, int b, int c) GMEM_EXCEP { +void *gmallocn3(int a, int b, int c) { return gmallocn3(a, b, c, false); } -void *gmallocn3_checkoverflow(int a, int b, int c) GMEM_EXCEP { +void *gmallocn3_checkoverflow(int a, int b, int c) { return gmallocn3(a, b, c, true); } -inline static void *greallocn(void *p, int nObjs, int objSize, bool checkoverflow) GMEM_EXCEP { +inline static void *greallocn(void *p, int nObjs, int objSize, bool checkoverflow) { int n; if (nObjs == 0) { @@ -249,22 +229,18 @@ inline static void *greallocn(void *p, int nObjs, int objSize, bool checkoverflo } n = nObjs * objSize; if (objSize <= 0 || nObjs < 0 || nObjs >= INT_MAX / objSize) { -#if USE_EXCEPTIONS - throw GMemException(); -#else fprintf(stderr, "Bogus memory allocation size\n"); if (checkoverflow) return NULL; else exit(1); -#endif } return grealloc(p, n, checkoverflow); } -void *greallocn(void *p, int nObjs, int objSize) GMEM_EXCEP { +void *greallocn(void *p, int nObjs, int objSize) { return greallocn(p, nObjs, objSize, false); } -void *greallocn_checkoverflow(void *p, int nObjs, int objSize) GMEM_EXCEP { +void *greallocn_checkoverflow(void *p, int nObjs, int objSize) { return greallocn(p, nObjs, objSize, true); } @@ -14,7 +14,7 @@ // under GPL version 2 or later // // Copyright (C) 2005 Takashi Iwai <tiwai@suse.de> -// Copyright (C) 2007-2009 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2007-2010 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2008 Jonathan Kew <jonathan_kew@sil.org> // // To see a description of the changes please see the Changelog file that @@ -28,22 +28,6 @@ #include <stdio.h> #include "poppler/poppler-config.h" -#if USE_EXCEPTIONS - -class GMemException { -public: - GMemException() {} - ~GMemException() {} -}; - -#define GMEM_EXCEP throw(GMemException) - -#else // USE_EXCEPTIONS - -#define GMEM_EXCEP - -#endif // USE_EXCEPTIONS - #ifdef __cplusplus extern "C" { #endif @@ -52,15 +36,15 @@ extern "C" { * Same as malloc, but prints error message and exits if malloc() * returns NULL. */ -extern void *gmalloc(size_t size) GMEM_EXCEP; -extern void *gmalloc_checkoverflow(size_t size) GMEM_EXCEP; +extern void *gmalloc(size_t size); +extern void *gmalloc_checkoverflow(size_t size); /* * Same as realloc, but prints error message and exits if realloc() * returns NULL. If <p> is NULL, calls malloc instead of realloc(). */ -extern void *grealloc(void *p, size_t size) GMEM_EXCEP; -extern void *grealloc_checkoverflow(size_t size) GMEM_EXCEP; +extern void *grealloc(void *p, size_t size); +extern void *grealloc_checkoverflow(size_t size); /* * These are similar to gmalloc and grealloc, but take an object count @@ -70,12 +54,12 @@ extern void *grealloc_checkoverflow(size_t size) GMEM_EXCEP; * The gmallocn_checkoverflow variant returns NULL instead of exiting * the application if a overflow is detected */ -extern void *gmallocn(int nObjs, int objSize) GMEM_EXCEP; -extern void *gmallocn_checkoverflow(int nObjs, int objSize) GMEM_EXCEP; -extern void *gmallocn3(int a, int b, int c) GMEM_EXCEP; -extern void *gmallocn3_checkoverflow(int a, int b, int c) GMEM_EXCEP; -extern void *greallocn(void *p, int nObjs, int objSize) GMEM_EXCEP; -extern void *greallocn_checkoverflow(void *p, int nObjs, int objSize) GMEM_EXCEP; +extern void *gmallocn(int nObjs, int objSize); +extern void *gmallocn_checkoverflow(int nObjs, int objSize); +extern void *gmallocn3(int a, int b, int c); +extern void *gmallocn3_checkoverflow(int a, int b, int c); +extern void *greallocn(void *p, int nObjs, int objSize); +extern void *greallocn_checkoverflow(void *p, int nObjs, int objSize); /* * Same as free, but checks for and ignores NULL pointers. diff --git a/poppler/poppler-config.h.cmake b/poppler/poppler-config.h.cmake index d049a121..2243498b 100644 --- a/poppler/poppler-config.h.cmake +++ b/poppler/poppler-config.h.cmake @@ -19,11 +19,6 @@ #cmakedefine MULTITHREADED 1 #endif -/* Enable exceptions. */ -#ifndef USE_EXCEPTIONS -#cmakedefine USE_EXCEPTIONS 1 -#endif - /* Use fixedpoint. */ #ifndef USE_FIXEDPOINT #cmakedefine USE_FIXEDPOINT 1 diff --git a/poppler/poppler-config.h.in b/poppler/poppler-config.h.in index 6fa873ee..cc531e31 100644 --- a/poppler/poppler-config.h.in +++ b/poppler/poppler-config.h.in @@ -19,11 +19,6 @@ #undef MULTITHREADED #endif -/* Enable exceptions. */ -#ifndef USE_EXCEPTIONS -#undef USE_EXCEPTIONS -#endif - /* Use fixedpoint. */ #ifndef USE_FIXEDPOINT #undef USE_FIXEDPOINT |