moriyoshi Sun Aug 24 18:13:29 2003 EDT
Removed files:
/php-src/ext/mbstring php_mbfl_allocators.c
Modified files:
/php-src/ext/mbstring mbstring.c
Log:
Integrate allocator code into mbstring.c
Index: php-src/ext/mbstring/mbstring.c
diff -u php-src/ext/mbstring/mbstring.c:1.192 php-src/ext/mbstring/mbstring.c:1.193
--- php-src/ext/mbstring/mbstring.c:1.192 Sat Aug 23 06:04:42 2003
+++ php-src/ext/mbstring/mbstring.c Sun Aug 24 18:13:28 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: mbstring.c,v 1.192 2003/08/23 10:04:42 hirokawa Exp $ */
+/* $Id: mbstring.c,v 1.193 2003/08/24 22:13:28 moriyoshi Exp $ */
/*
* PHP4 Multibyte String module "mbstring"
@@ -60,6 +60,8 @@
#include "main/php_output.h"
#include "ext/standard/info.h"
+#include "mbfl/mbfl_allocators.h"
+
#include "php_variables.h"
#include "php_globals.h"
#include "rfc1867.h"
@@ -227,6 +229,53 @@
ZEND_GET_MODULE(mbstring)
#endif
+/* {{{ allocators */
+static void *_php_mb_allocators_malloc(unsigned int sz)
+{
+ return emalloc(sz);
+}
+
+static void *_php_mb_allocators_realloc(void *ptr, unsigned int sz)
+{
+ return erealloc(ptr, sz);
+}
+
+static void *_php_mb_allocators_calloc(unsigned int nelems, unsigned int szelem)
+{
+ return ecalloc(nelems, szelem);
+}
+
+static void _php_mb_allocators_free(void *ptr)
+{
+ efree(ptr);
+}
+
+static void *_php_mb_allocators_pmalloc(unsigned int sz)
+{
+ return pemalloc(sz, 1);
+}
+
+static void *_php_mb_allocators_prealloc(void *ptr, unsigned int sz)
+{
+ return perealloc(ptr, sz, 1);
+}
+
+static void _php_mb_allocators_pfree(void *ptr)
+{
+ pefree(ptr, 1);
+}
+
+static mbfl_allocators _php_mb_allocators = {
+ _php_mb_allocators_malloc,
+ _php_mb_allocators_realloc,
+ _php_mb_allocators_calloc,
+ _php_mb_allocators_free,
+ _php_mb_allocators_pmalloc,
+ _php_mb_allocators_prealloc,
+ _php_mb_allocators_pfree
+};
+/* }}} */
+
/* {{{ static int php_mb_parse_encoding_list()
* Return 0 if input contains any illegal encoding, otherwise 1.
* Even if any illegal encoding is detected the result may contain a list
@@ -663,6 +712,8 @@
/* {{{ PHP_MINIT_FUNCTION(mbstring) */
PHP_MINIT_FUNCTION(mbstring)
{
+ __mbfl_allocators = &_php_mb_allocators;
+
#ifdef ZTS
ts_allocate_id(&mbstring_globals_id, sizeof(zend_mbstring_globals),
(ts_allocate_ctor) _php_mb_globals_ctor,
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php