#define ZTS_V 0
#endif
+#include <unicode/utypes.h>
+
+typedef union _zstr {
+ char *s;
+ UChar *u;
+ void *v;
+} zstr;
+
#include "zend_errors.h"
#include "zend_alloc.h"
#include "zend_types.h"
-#include <unicode/utypes.h>
-
#ifdef HAVE_LIMITS_H
# include <limits.h>
#endif
#define LONG_MIN (- LONG_MAX - 1)
#endif
-typedef union _zstr {
- char *s;
- UChar *u;
- void *v;
-} zstr;
-
#ifdef __GNUC__
# define ZSTR(x) ((zstr)(x))
# define NULL_ZSTR ZSTR((void*)NULL)
return p;
}
+ZEND_API zstr zend_zstrndup(int type, const zstr s, uint length)
+{
+ if (type == IS_STRING) {
+ return zend_strndup(s.s, length);
+ } else {
+ return zend_ustrndup(s.u, length);
+ }
+}
ZEND_API int zend_set_memory_limit(unsigned int memory_limit)
{
ZEND_API char *zend_strndup(const char *s, unsigned int length) ZEND_ATTRIBUTE_MALLOC;
ZEND_API UChar *zend_ustrndup(const UChar *s, uint length) ZEND_ATTRIBUTE_MALLOC;
+ZEND_API zstr zend_zstrndup(int type, const zstr s, uint length) ZEND_ATTRIBUTE_MALLOC;
ZEND_API void *_emalloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC;
ZEND_API void *_safe_emalloc(size_t nmemb, size_t size, size_t offset ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC;