summaryrefslogtreecommitdiff
path: root/pcre_globals.c
diff options
context:
space:
mode:
authorph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2010-03-03 12:01:00 +0000
committerph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2010-03-03 12:01:00 +0000
commitd3ebf28a7ff375fe7681717ef4b0056138564e39 (patch)
tree2a8e48f40cc31405abee86296a916df9e07fef51 /pcre_globals.c
parent7b3e9efea8a44394eb40c2b5e98c1b5e1251bac6 (diff)
downloadpcre-d3ebf28a7ff375fe7681717ef4b0056138564e39.tar.gz
Use local function indirection for pcre_malloc etc. for Visual Studio and
Symbian. git-svn-id: svn://vcs.exim.org/pcre/code/trunk@497 2f5784b3-3f2a-0410-8824-cb99058d5e15
Diffstat (limited to 'pcre_globals.c')
-rw-r--r--pcre_globals.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/pcre_globals.c b/pcre_globals.c
index 24ed03d..10d0b2b 100644
--- a/pcre_globals.c
+++ b/pcre_globals.c
@@ -43,8 +43,14 @@ PCRE is thread-clean and doesn't use any global variables in the normal sense.
However, it calls memory allocation and freeing functions via the four
indirections below, and it can optionally do callouts, using the fifth
indirection. These values can be changed by the caller, but are shared between
-all threads. However, when compiling for Virtual Pascal, things are done
-differently, and global variables are not used (see pcre.in). */
+all threads.
+
+For MS Visual Studio and Symbian OS, there are problems in initializing these
+variables to non-local functions. In these cases, therefore, an indirection via
+a local function is used.
+
+Also, when compiling for Virtual Pascal, things are done differently, and
+global variables are not used. */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -52,7 +58,22 @@ differently, and global variables are not used (see pcre.in). */
#include "pcre_internal.h"
-#ifndef VPCOMPAT
+#if defined _MSC_VER || defined __SYMBIAN32__
+static void* LocalPcreMalloc(size_t aSize)
+ {
+ return malloc(aSize);
+ }
+static void LocalPcreFree(void* aPtr)
+ {
+ free(aPtr);
+ }
+PCRE_EXP_DATA_DEFN void *(*pcre_malloc)(size_t) = LocalPcreMalloc;
+PCRE_EXP_DATA_DEFN void (*pcre_free)(void *) = LocalPcreFree;
+PCRE_EXP_DATA_DEFN void *(*pcre_stack_malloc)(size_t) = LocalPcreMalloc;
+PCRE_EXP_DATA_DEFN void (*pcre_stack_free)(void *) = LocalPcreFree;
+PCRE_EXP_DATA_DEFN int (*pcre_callout)(pcre_callout_block *) = NULL;
+
+#elif !defined VPCOMPAT
PCRE_EXP_DATA_DEFN void *(*pcre_malloc)(size_t) = malloc;
PCRE_EXP_DATA_DEFN void (*pcre_free)(void *) = free;
PCRE_EXP_DATA_DEFN void *(*pcre_stack_malloc)(size_t) = malloc;