| Sara Golemon 2007-01-07, 3:57 am |
| pollita Sun Jan 7 05:24:56 2007 UTC
Modified files:
/ZendEngine2 zend_alloc.c zend_alloc.h
Log:
Flesh out some missing API calls
http://cvs.php.net/viewvc.cgi/ZendE...7&diff_format=u
Index: ZendEngine2/zend_alloc.c
diff -u ZendEngine2/zend_alloc.c:1.186 ZendEngine2/zend_alloc.c:1.187
--- ZendEngine2/zend_alloc.c:1.186 Mon Jan 1 09:29:20 2007
+++ ZendEngine2/zend_alloc.c Sun Jan 7 05:24:55 2007
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_alloc.c,v 1.186 2007/01/01 09:29:20 sebastian Exp $ */
+/* $Id: zend_alloc.c,v 1.187 2007/01/07 05:24:55 pollita Exp $ */
#include "zend.h"
#include "zend_alloc.h"
@@ -2013,6 +2013,32 @@
return p;
}
+ZEND_API UChar *_peustrdup(const UChar *s)
+{
+ int length;
+ UChar *p;
+
+ length = u_strlen(s)+1;
+ p = (UChar *) malloc(sizeof(UChar) * length);
+ if (!p) {
+ return (UChar *)NULL;
+ }
+ u_memcpy(p, s, length);
+ return p;
+}
+
+ZEND_API UChar *_peustrndup(const UChar *s, int length)
+{
+ UChar *p;
+
+ p = (UChar *) malloc(sizeof(UChar) * (length+1));
+ if (!p) {
+ return (UChar *)NULL;
+ }
+ memcpy(p, s, length * sizeof(UChar));
+ p[length] = 0;
+ return p;
+}
ZEND_API zstr _ezstrndup(int type, const zstr s, uint length ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
{
http://cvs.php.net/viewvc.cgi/ZendE...2&diff_format=u
Index: ZendEngine2/zend_alloc.h
diff -u ZendEngine2/zend_alloc.h:1.81 ZendEngine2/zend_alloc.h:1.82
--- ZendEngine2/zend_alloc.h:1.81 Mon Jan 1 09:29:20 2007
+++ ZendEngine2/zend_alloc.h Sun Jan 7 05:24:55 2007
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_alloc.h,v 1.81 2007/01/01 09:29:20 sebastian Exp $ */
+/* $Id: zend_alloc.h,v 1.82 2007/01/07 05:24:55 pollita Exp $ */
#ifndef ZEND_ALLOC_H
#define ZEND_ALLOC_H
@@ -55,6 +55,8 @@
ZEND_API UChar *_eustrndup(const UChar *s, int length ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC;
ZEND_API zstr _ezstrndup(int type, const zstr s, uint length ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
ZEND_API size_t _zend_mem_block_size(void *ptr TSRMLS_DC ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
+ZEND_API UChar *_peustrdup(const UChar *s) ZEND_ATTRIBUTE_MALLOC;
+ZEND_API UChar *_peustrndup(const UChar *s, int length) ZEND_ATTRIBUTE_MALLOC;
/* Standard wrapper macros */
#define emalloc(size) _emalloc((size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
@@ -94,6 +96,8 @@
#define pestrdup(s, persistent) ((persistent)?strdup(s):estrdup(s))
#define peumalloc(size, persistent) ((persistent)?malloc(UBYTES(size)):eumalloc(size))
#define peurealloc(ptr, size, persistent) ((persistent)? realloc((ptr),UBYTES(size)):eurealloc((p
tr),size))
+#define peustrdup(s, persistent) ((persistent)?_peustrdup((s)):eustrdup((s)))
+#define peustrndup(s, length, persistent) ((persistent)? _peustrndup((s),(length)):eustrndup((s),
(length)))
#define pemalloc_rel(size, persistent) ((persistent)?malloc(size):emalloc_rel(size))
#define pefree_rel(ptr, persistent) ((persistent)?free(ptr):efree_rel(ptr))
@@ -104,6 +108,8 @@
#define safe_estrdup(ptr) ((ptr)?(estrdup(ptr)):STR_EMPTY_ALLOC())
#define safe_estrndup(ptr, len) ((ptr)?(estrndup((ptr), (len))):STR_EMPTY_ALLOC())
+#define safe_eustrdup(ptr) ((ptr)?(eustrdup((ptr))):STR_EMPTY_ALLOC())
+#define safe_eustrndup(ptr, len) ((ptr)? (eustrndup((ptr),(leng))):STR_EMPTY_ALLO
C())
ZEND_API int zend_set_memory_limit(unsigned int memory_limit);
|