From 4a98596c90760bf6f38bcd23dd49c364fb298d10 Mon Sep 17 00:00:00 2001 From: Antony Dovgal Date: Fri, 20 Oct 2006 10:33:31 +0000 Subject: [PATCH] rename REAL_KEY_SIZE() to USTR_BYTES() and move to zend_unicode.h this macro is going to be actively used in Unicode version of OCI8 (and other extensions, probably) --- Zend/zend_hash.c | 16 ++++++++-------- Zend/zend_hash.h | 4 +--- Zend/zend_unicode.h | 3 +++ 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c index e471b1aa70..2540bd663d 100644 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@ -246,7 +246,7 @@ ZEND_API int _zend_u_hash_add_or_update(HashTable *ht, zend_uchar type, zstr arK } UNICODE_KEY(ht, type, arKey, nKeyLength, tmp); - realKeyLength = REAL_KEY_SIZE(type, nKeyLength); + realKeyLength = USTR_BYTES(type, nKeyLength); h = zend_u_inline_hash_func(type, arKey, nKeyLength); nIndex = h & ht->nTableMask; @@ -399,7 +399,7 @@ ZEND_API int _zend_u_hash_quick_add_or_update(HashTable *ht, zend_uchar type, zs UNICODE_KEY(ht, type, arKey, nKeyLength, tmp); h = zend_u_inline_hash_func(IS_UNICODE, arKey, nKeyLength); } - realKeyLength = REAL_KEY_SIZE(type, nKeyLength); + realKeyLength = USTR_BYTES(type, nKeyLength); nIndex = h & ht->nTableMask; @@ -606,7 +606,7 @@ ZEND_API int zend_u_hash_del_key_or_index(HashTable *ht, zend_uchar type, zstr a if (flag == HASH_DEL_KEY) { UNICODE_KEY(ht, type, arKey, nKeyLength, tmp); - realKeyLength = REAL_KEY_SIZE(type, nKeyLength); + realKeyLength = USTR_BYTES(type, nKeyLength); h = zend_u_inline_hash_func(type, arKey, nKeyLength); } nIndex = h & ht->nTableMask; @@ -1081,7 +1081,7 @@ ZEND_API int zend_u_hash_find(HashTable *ht, zend_uchar type, zstr arKey, uint n IS_CONSISTENT(ht); UNICODE_KEY(ht, type, arKey, nKeyLength, tmp); - realKeyLength = REAL_KEY_SIZE(type, nKeyLength); + realKeyLength = USTR_BYTES(type, nKeyLength); h = zend_u_inline_hash_func(type, arKey, nKeyLength); nIndex = h & ht->nTableMask; @@ -1189,7 +1189,7 @@ ZEND_API int zend_u_hash_quick_find(HashTable *ht, zend_uchar type, zstr arKey, UNICODE_KEY(ht, type, arKey, nKeyLength, tmp); h = zend_u_inline_hash_func(IS_UNICODE, arKey, nKeyLength); } - realKeyLength = REAL_KEY_SIZE(type, nKeyLength); + realKeyLength = USTR_BYTES(type, nKeyLength); nIndex = h & ht->nTableMask; @@ -1225,7 +1225,7 @@ ZEND_API int zend_u_hash_exists(HashTable *ht, zend_uchar type, zstr arKey, uint IS_CONSISTENT(ht); UNICODE_KEY(ht, type, arKey, nKeyLength, tmp); - realKeyLength = REAL_KEY_SIZE(type, nKeyLength); + realKeyLength = USTR_BYTES(type, nKeyLength); h = zend_u_inline_hash_func(type, arKey, nKeyLength); nIndex = h & ht->nTableMask; @@ -1332,7 +1332,7 @@ ZEND_API int zend_u_hash_quick_exists(HashTable *ht, zend_uchar type, zstr arKey UNICODE_KEY(ht, type, arKey, nKeyLength, tmp); h = zend_u_inline_hash_func(type, arKey, nKeyLength); } - realKeyLength = REAL_KEY_SIZE(type, nKeyLength); + realKeyLength = USTR_BYTES(type, nKeyLength); nIndex = h & ht->nTableMask; @@ -1748,7 +1748,7 @@ ZEND_API int zend_hash_compare(HashTable *ht1, HashTable *ht2, compare_func_t co result = p1->nKeyLength - p2->nKeyLength; } if (result==0) { - result = memcmp(p1->key.arKey.s, p2->key.arKey.s, REAL_KEY_SIZE(p1->key.type, p1->nKeyLength)); + result = memcmp(p1->key.arKey.s, p2->key.arKey.s, USTR_BYTES(p1->key.type, p1->nKeyLength)); } if (result!=0) { HASH_UNPROTECT_RECURSION(ht1); diff --git a/Zend/zend_hash.h b/Zend/zend_hash.h index 2245ff5574..e572bdb21d 100644 --- a/Zend/zend_hash.h +++ b/Zend/zend_hash.h @@ -37,8 +37,6 @@ #define HASH_DEL_KEY 0 #define HASH_DEL_INDEX 1 -#define REAL_KEY_SIZE(type, nKeyLength) \ - ((type == IS_UNICODE)?UBYTES(nKeyLength):nKeyLength) typedef ulong (*hash_func_t)(char *arKey, uint nKeyLength); @@ -336,7 +334,7 @@ EMPTY_SWITCH_DEFAULT_CASE() } #define zend_u_inline_hash_func(type, arKey, nKeyLength) \ - zend_inline_hash_func(arKey.s, REAL_KEY_SIZE(type, nKeyLength)) + zend_inline_hash_func(arKey.s, USTR_BYTES(type, nKeyLength)) ZEND_API ulong zend_hash_func(char *arKey, uint nKeyLength); ZEND_API ulong zend_u_hash_func(zend_uchar type, zstr arKey, uint nKeyLength); diff --git a/Zend/zend_unicode.h b/Zend/zend_unicode.h index f956929342..c77e972382 100644 --- a/Zend/zend_unicode.h +++ b/Zend/zend_unicode.h @@ -136,6 +136,9 @@ static inline int zend_codepoint_to_uchar(UChar32 codepoint, UChar *buf) #define USTR_LEN(str) (UG(unicode)?u_strlen((str).u):strlen((str).s)) #define USTR_VAL(str) (UG(unicode)?(str).u:(str).s) +#define USTR_BYTES(__type, __length) \ + ((__type == IS_UNICODE)?UBYTES(__length):__length) + #define USTR_MAKE(cs) zend_ascii_to_unicode(cs, sizeof(cs) ZEND_FILE_LINE_CC) #define USTR_MAKE_REL(cs) zend_ascii_to_unicode(cs, sizeof(cs) ZEND_FILE_LINE_RELAY_CC) static inline UChar* zend_ascii_to_unicode(const char *cs, size_t cs_size ZEND_FILE_LINE_DC) -- 2.50.1