[Pcre-svn] [497] code/trunk: Use local function indirection …

トップ ページ
このメッセージを削除
著者: Subversion repository
日付:  
To: pcre-svn
題目: [Pcre-svn] [497] code/trunk: Use local function indirection for pcre_malloc etc.
Revision: 497
          http://vcs.pcre.org/viewvc?view=rev&revision=497
Author:   ph10
Date:     2010-03-03 12:01:00 +0000 (Wed, 03 Mar 2010)


Log Message:
-----------
Use local function indirection for pcre_malloc etc. for Visual Studio and
Symbian.

Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/pcre_globals.c


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2010-03-02 19:11:17 UTC (rev 496)
+++ code/trunk/ChangeLog    2010-03-03 12:01:00 UTC (rev 497)
@@ -19,6 +19,11 @@
     quantifier applied to a forward-referencing subroutine call, could compile
     incorrect code or give the error "internal error: previously-checked
     referenced subpattern not found".
+    
+6.  Both MS Visual Studio and Symbian OS have problems with initializing 
+    variables to point to external functions. For these systems, therefore,
+    pcre_malloc etc. are now initialized to local functions that call the
+    relevant global functions.



Version 8.01 19-Jan-2010

Modified: code/trunk/pcre_globals.c
===================================================================
--- code/trunk/pcre_globals.c    2010-03-02 19:11:17 UTC (rev 496)
+++ code/trunk/pcre_globals.c    2010-03-03 12:01:00 UTC (rev 497)
@@ -43,16 +43,37 @@
 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"
#endif

#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;