Browse Source

ws fix

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@1459 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
master
Xuefer 8 years ago
parent
commit
eec21f3c52
  1. 136
      processor/hashtable.m4

136
processor/hashtable.m4

@ -1,71 +1,72 @@
dnl DEF_HASH_TABLE_FUNC(1:name, 2:datatype [, 3:dataname])
define(`DEF_HASH_TABLE_FUNC', `
DEF_STRUCT_P_FUNC(`HashTable', `$1', `
pushdefFUNC_NAME(`$2', `$3')
dnl {{{ dasm
IFDASM(`
const Bucket *srcBucket;
zval *zv;
int bufsize = 2;
char *buf = emalloc(bufsize);
int keysize;
define(`DEF_HASH_TABLE_FUNC', `DEF_STRUCT_P_FUNC(`HashTable', `$1', `
pushdefFUNC_NAME(`$2', `$3')
dnl {{{ dasm
IFDASM(`
const Bucket *srcBucket;
zval *zv;
int bufsize = 2;
char *buf = emalloc(bufsize);
int keysize;
define(`AUTOCHECK_SKIP')
IFAUTOCHECK(`xc_autocheck_skip = 1;')
define(`AUTOCHECK_SKIP')
IFAUTOCHECK(`xc_autocheck_skip = 1;')
DISABLECHECK(`
for (srcBucket = SRC(`pListHead'); srcBucket != NULL; srcBucket = srcBucket->pListNext) {
ALLOC_INIT_ZVAL(zv);
array_init(zv);
FUNC_NAME (dasm, zv, (($2*)srcBucket->pData) TSRMLS_CC);
keysize = BUCKET_KEY_SIZE(srcBucket) + 2;
if (keysize > bufsize) {
do {
bufsize *= 2;
} while (keysize > bufsize);
buf = erealloc(buf, bufsize);
}
memcpy(buf, BUCKET_KEY_S(srcBucket), keysize);
buf[keysize - 2] = buf[keysize - 1] = ""[0];
keysize = srcBucket->nKeyLength;
DISABLECHECK(`
for (srcBucket = SRC(`pListHead'); srcBucket != NULL; srcBucket = srcBucket->pListNext) {
ALLOC_INIT_ZVAL(zv);
array_init(zv);
FUNC_NAME (dasm, zv, (($2*)srcBucket->pData) TSRMLS_CC);
keysize = BUCKET_KEY_SIZE(srcBucket) + 2;
if (keysize > bufsize) {
do {
bufsize *= 2;
} while (keysize > bufsize);
buf = erealloc(buf, bufsize);
}
memcpy(buf, BUCKET_KEY_S(srcBucket), keysize);
buf[keysize - 2] = buf[keysize - 1] = ""[0];
keysize = srcBucket->nKeyLength;
#ifdef IS_UNICODE
if (BUCKET_KEY_TYPE(srcBucket) == IS_UNICODE) {
if (buf[0] == ""[0] && buf[1] == ""[0]) {
keysize ++;
}
} else
if (BUCKET_KEY_TYPE(srcBucket) == IS_UNICODE) {
if (buf[0] == ""[0] && buf[1] == ""[0]) {
keysize ++;
}
} else
#endif
{
if (buf[0] == ""[0]) {
keysize ++;
}
{
if (buf[0] == ""[0]) {
keysize ++;
}
add_u_assoc_zval_ex(dst, BUCKET_KEY_TYPE(srcBucket), ZSTR(buf), keysize, zv);
}
')
add_u_assoc_zval_ex(dst, BUCKET_KEY_TYPE(srcBucket), ZSTR(buf), keysize, zv);
}
')
efree(buf);
', ` dnl IFDASM else
dnl }}}
Bucket *srcBucket;
IFCOPY(`Bucket *dstBucket = NULL, *prev = NULL;')
zend_bool first = 1;
dnl only used for copy
IFCOPY(`uint n;')
IFCALCCOPY(`size_t bucketsize;')
efree(buf);
', ` dnl IFDASM else
dnl }}}
Bucket *srcBucket;
IFCOPY(`Bucket *dstBucket = NULL, *prev = NULL;')
zend_bool first = 1;
dnl only used for copy
IFCOPY(`uint n;')
IFCALCCOPY(`size_t bucketsize;')
#if defined(HARDENING_PATCH_HASH_PROTECT) && HARDENING_PATCH_HASH_PROTECT
IFRESTORE(`DST(`canary') = zend_hash_canary; DONE(canary)', `
dnl else
PROCESS(unsigned int, canary)
')
IFRESTORE(`
DST(`canary') = zend_hash_canary;
DONE(canary)
', `
PROCESS(unsigned int, canary)
')
#endif
PROCESS(uint, nTableSize)
PROCESS(uint, nTableMask)
PROCESS(uint, nNumOfElements)
PROCESS(ulong, nNextFreeElement)
IFCOPY(`DST(`pInternalPointer') = NULL; /* Used for element traversal */') DONE(pInternalPointer)
IFCOPY(`DST(`pListHead') = NULL;') DONE(pListHead)
PROCESS(uint, nTableSize)
PROCESS(uint, nTableMask)
PROCESS(uint, nNumOfElements)
PROCESS(ulong, nNextFreeElement)
IFCOPY(`DST(`pInternalPointer') = NULL; /* Used for element traversal */') DONE(pInternalPointer)
IFCOPY(`DST(`pListHead') = NULL;') DONE(pListHead)
#ifdef ZEND_ENGINE_2_4
if (SRC(`nTableMask')) {
#endif
@ -141,18 +142,17 @@ define(`DEF_HASH_TABLE_FUNC', `
DONE(arBuckets)
}
#endif
IFCOPY(`DST(`pListTail') = dstBucket;') DONE(pListTail)
IFCOPY(`DST(`pDestructor') = SRC(`pDestructor');') DONE(pDestructor)
PROCESS(zend_bool, persistent)
IFCOPY(`DST(`pListTail') = dstBucket;') DONE(pListTail)
IFCOPY(`DST(`pDestructor') = SRC(`pDestructor');') DONE(pDestructor)
PROCESS(zend_bool, persistent)
#ifdef IS_UNICODE
PROCESS(zend_bool, unicode)
PROCESS(zend_bool, unicode)
#endif
PROCESS(unsigned char, nApplyCount)
PROCESS(zend_bool, bApplyProtection)
PROCESS(unsigned char, nApplyCount)
PROCESS(zend_bool, bApplyProtection)
#if ZEND_DEBUG
PROCESS(int, inconsistent)
PROCESS(int, inconsistent)
#endif
')dnl IFDASM
popdef(`FUNC_NAME')
')
')
')dnl IFDASM
popdef(`FUNC_NAME')
')')

Loading…
Cancel
Save