[glib/wip/pcre-8.30: 6/8] regex: Use glib memory allocator



commit a0fd66eb0cb586c0155516d5b9620e232cbb70da
Author: Christian Persch <chpe gnome org>
Date:   Sun Feb 12 19:40:48 2012 +0100

    regex: Use glib memory allocator

 glib/pcre/pcre_globals.c      |   10 ++--
 glib/update-pcre/memory.patch |  114 ++++++++++++----------------------------
 2 files changed, 40 insertions(+), 84 deletions(-)
---
diff --git a/glib/pcre/pcre_globals.c b/glib/pcre/pcre_globals.c
index 36e6ddb..93d3af5 100644
--- a/glib/pcre/pcre_globals.c
+++ b/glib/pcre/pcre_globals.c
@@ -58,6 +58,8 @@ global variables are not used. */
 
 #include "pcre_internal.h"
 
+#include "gmem.h"
+
 #if defined _MSC_VER || defined  __SYMBIAN32__
 static void* LocalPcreMalloc(size_t aSize)
   {
@@ -74,10 +76,10 @@ PCRE_EXP_DATA_DEFN void  (*PUBL(stack_free))(void *) = LocalPcreFree;
 PCRE_EXP_DATA_DEFN int   (*PUBL(callout))(PUBL(callout_block) *) = NULL;
 
 #elif !defined VPCOMPAT
-PCRE_EXP_DATA_DEFN void *(*PUBL(malloc))(size_t) = malloc;
-PCRE_EXP_DATA_DEFN void  (*PUBL(free))(void *) = free;
-PCRE_EXP_DATA_DEFN void *(*PUBL(stack_malloc))(size_t) = malloc;
-PCRE_EXP_DATA_DEFN void  (*PUBL(stack_free))(void *) = free;
+PCRE_EXP_DATA_DEFN void *(*PUBL(malloc))(size_t) = g_try_malloc;
+PCRE_EXP_DATA_DEFN void  (*PUBL(free))(void *) = g_free;
+PCRE_EXP_DATA_DEFN void *(*PUBL(stack_malloc))(size_t) = g_try_malloc;
+PCRE_EXP_DATA_DEFN void  (*PUBL(stack_free))(void *) = g_free;
 PCRE_EXP_DATA_DEFN int   (*PUBL(callout))(PUBL(callout_block) *) = NULL;
 #endif
 
diff --git a/glib/update-pcre/memory.patch b/glib/update-pcre/memory.patch
index e74a399..f3a04c7 100644
--- a/glib/update-pcre/memory.patch
+++ b/glib/update-pcre/memory.patch
@@ -1,86 +1,40 @@
-diff -r 0f4042339eb5 pcre/pcre.h
---- pcre/pcre.h	Tue Jul 25 22:39:16 2006 +0200
-+++ pcre/pcre.h	Tue Jul 25 22:52:10 2006 +0200
-@@ -233,25 +233,13 @@ typedef struct pcre_callout_block {
-   /* ------------------------------------------------------------------ */
- } pcre_callout_block;
- 
--/* Indirection for store get and free functions. These can be set to
--alternative malloc/free functions if required. Special ones are used in the
--non-recursive case for "frames". There is also an optional callout function
--that is triggered by the (?) regex item. For Virtual Pascal, these definitions
--have to take another form. */
--
--#ifndef VPCOMPAT
--PCRE_DATA_SCOPE void *(*pcre_malloc)(size_t);
--PCRE_DATA_SCOPE void  (*pcre_free)(void *);
--PCRE_DATA_SCOPE void *(*pcre_stack_malloc)(size_t);
--PCRE_DATA_SCOPE void  (*pcre_stack_free)(void *);
-+#include "glib.h"
-+
-+#define pcre_malloc g_try_malloc
-+#define pcre_free g_free
-+#define pcre_stack_malloc g_try_malloc
-+
- PCRE_DATA_SCOPE int   (*pcre_callout)(pcre_callout_block *);
--#else   /* VPCOMPAT */
--PCRE_DATA_SCOPE void *pcre_malloc(size_t);
--PCRE_DATA_SCOPE void  pcre_free(void *);
--PCRE_DATA_SCOPE void *pcre_stack_malloc(size_t);
--PCRE_DATA_SCOPE void  pcre_stack_free(void *);
--PCRE_DATA_SCOPE int   pcre_callout(pcre_callout_block *);
--#endif  /* VPCOMPAT */
- 
- /* Exported PCRE functions */
+From acf401f1353a37b6edff9577ff07d055c625e4ca Mon Sep 17 00:00:00 2001
+From: Christian Persch <chpe gnome org>
+Date: Sun, 12 Feb 2012 19:40:48 +0100
+Subject: [PATCH] regex: Use glib memory allocator
+
+---
+ glib/pcre/pcre_globals.c |   10 ++++++----
+ 1 files changed, 6 insertions(+), 4 deletions(-)
+
+diff --git a/glib/pcre/pcre_globals.c b/glib/pcre/pcre_globals.c
+index 36e6ddb..93d3af5 100644
+--- a/glib/pcre/pcre_globals.c
++++ b/glib/pcre/pcre_globals.c
+@@ -58,6 +58,8 @@ global variables are not used. */
  
-diff -r 0f4042339eb5 pcre/pcre_globals.c
---- pcre/pcre_globals.c	Tue Jul 25 22:39:16 2006 +0200
-+++ pcre/pcre_globals.c	Tue Jul 25 22:52:10 2006 +0200
-@@ -50,32 +50,9 @@ differently, and global variables are no
  #include "pcre_internal.h"
  
- 
--#ifndef VPCOMPAT
--
--/**************************************************************************
--This code used to be here for use when compiling as a C++ library. However,
--according to Dair Grant it is not needed: "
--
-- Including 'extern "C"' in the declaration generates an "initialized and
-- declared `extern'" warning from gcc 4.0.1. Since we include pcre_internal.h,
-- which includes pcre.h, which declares these prototypes within an extern "C" {}
-- block, we shouldn't need the prefix here.
--
--So, from Release 7.0 I have cut this out.
--
- #ifdef __cplusplus
--extern "C" void *(*pcre_malloc)(size_t) = malloc;
--extern "C" void  (*pcre_free)(void *) = free;
--extern "C" void *(*pcre_stack_malloc)(size_t) = malloc;
--extern "C" void  (*pcre_stack_free)(void *) = free;
- extern "C" int   (*pcre_callout)(pcre_callout_block *) = NULL;
- #else
--**************************************************************************/
--
--void *(*pcre_malloc)(size_t) = malloc;
--void  (*pcre_free)(void *) = free;
--void *(*pcre_stack_malloc)(size_t) = malloc;
--void  (*pcre_stack_free)(void *) = free;
- int   (*pcre_callout)(pcre_callout_block *) = NULL;
++#include "gmem.h"
++
+ #if defined _MSC_VER || defined  __SYMBIAN32__
+ static void* LocalPcreMalloc(size_t aSize)
+   {
+@@ -74,10 +76,10 @@ PCRE_EXP_DATA_DEFN void  (*PUBL(stack_free))(void *) = LocalPcreFree;
+ PCRE_EXP_DATA_DEFN int   (*PUBL(callout))(PUBL(callout_block) *) = NULL;
+ 
+ #elif !defined VPCOMPAT
+-PCRE_EXP_DATA_DEFN void *(*PUBL(malloc))(size_t) = malloc;
+-PCRE_EXP_DATA_DEFN void  (*PUBL(free))(void *) = free;
+-PCRE_EXP_DATA_DEFN void *(*PUBL(stack_malloc))(size_t) = malloc;
+-PCRE_EXP_DATA_DEFN void  (*PUBL(stack_free))(void *) = free;
++PCRE_EXP_DATA_DEFN void *(*PUBL(malloc))(size_t) = g_try_malloc;
++PCRE_EXP_DATA_DEFN void  (*PUBL(free))(void *) = g_free;
++PCRE_EXP_DATA_DEFN void *(*PUBL(stack_malloc))(size_t) = g_try_malloc;
++PCRE_EXP_DATA_DEFN void  (*PUBL(stack_free))(void *) = g_free;
+ PCRE_EXP_DATA_DEFN int   (*PUBL(callout))(PUBL(callout_block) *) = NULL;
  #endif
  
-diff -r 0f4042339eb5 pcre/pcre_internal.h
---- pcre/pcre_internal.h	Tue Jul 25 22:39:16 2006 +0200
-+++ pcre/pcre_internal.h	Tue Jul 25 22:52:10 2006 +0200
-@@ -480,10 +480,7 @@ variable-length repeat, or a anything ot
- 
- /* Miscellaneous definitions */
- 
--typedef int BOOL;
--
--#define FALSE   0
--#define TRUE    1
-+typedef gboolean BOOL;
- 
- /* Escape items that are just an encoding of a particular data value. */
+-- 
+1.7.5.1.217.g4e3aa.dirty
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]