From: Dmitry Stogov Date: Thu, 28 Nov 2013 13:02:01 +0000 (+0400) Subject: Some rare deprecated cases replaced by ZEND_ASSERT() (some extensions might need... X-Git-Tag: php-5.6.0alpha1~166 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b63b81815fa29e53cd1bd9e710efe568afbafdfb;p=php Some rare deprecated cases replaced by ZEND_ASSERT() (some extensions might need to be fixed) --- diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c index 5d81c285d4..00ee6b88c2 100644 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@ -199,12 +199,7 @@ ZEND_API int _zend_hash_add_or_update(HashTable *ht, const char *arKey, uint nKe IS_CONSISTENT(ht); - if (nKeyLength <= 0) { -#if ZEND_DEBUG - ZEND_PUTS("zend_hash_update: Can't put in empty key\n"); -#endif - return FAILURE; - } + ZEND_ASSERT(nKeyLength != 0); CHECK_INIT(ht); @@ -218,14 +213,8 @@ ZEND_API int _zend_hash_add_or_update(HashTable *ht, const char *arKey, uint nKe if (flag & HASH_ADD) { return FAILURE; } + ZEND_ASSERT(p->pData != pData); HANDLE_BLOCK_INTERRUPTIONS(); -#if ZEND_DEBUG - if (p->pData == pData) { - ZEND_PUTS("Fatal error in zend_hash_update: p->pData == pData\n"); - HANDLE_UNBLOCK_INTERRUPTIONS(); - return FAILURE; - } -#endif if (ht->pDestructor) { ht->pDestructor(p->pData); } @@ -275,9 +264,7 @@ ZEND_API int _zend_hash_quick_add_or_update(HashTable *ht, const char *arKey, ui IS_CONSISTENT(ht); - if (nKeyLength == 0) { - return zend_hash_index_update(ht, h, pData, nDataSize, pDest); - } + ZEND_ASSERT(nKeyLength != 0); CHECK_INIT(ht); nIndex = h & ht->nTableMask; @@ -289,14 +276,8 @@ ZEND_API int _zend_hash_quick_add_or_update(HashTable *ht, const char *arKey, ui if (flag & HASH_ADD) { return FAILURE; } + ZEND_ASSERT(p->pData != pData); HANDLE_BLOCK_INTERRUPTIONS(); -#if ZEND_DEBUG - if (p->pData == pData) { - ZEND_PUTS("Fatal error in zend_hash_update: p->pData == pData\n"); - HANDLE_UNBLOCK_INTERRUPTIONS(); - return FAILURE; - } -#endif if (ht->pDestructor) { ht->pDestructor(p->pData); } @@ -370,14 +351,8 @@ ZEND_API int _zend_hash_index_update_or_next_insert(HashTable *ht, ulong h, void if (flag & HASH_NEXT_INSERT || flag & HASH_ADD) { return FAILURE; } + ZEND_ASSERT(p->pData != pData); HANDLE_BLOCK_INTERRUPTIONS(); -#if ZEND_DEBUG - if (p->pData == pData) { - ZEND_PUTS("Fatal error in zend_hash_index_update: p->pData == pData\n"); - HANDLE_UNBLOCK_INTERRUPTIONS(); - return FAILURE; - } -#endif if (ht->pDestructor) { ht->pDestructor(p->pData); } @@ -909,9 +884,7 @@ ZEND_API int zend_hash_quick_find(const HashTable *ht, const char *arKey, uint n uint nIndex; Bucket *p; - if (nKeyLength==0) { - return zend_hash_index_find(ht, h, pData); - } + ZEND_ASSERT(nKeyLength != 0); IS_CONSISTENT(ht); @@ -958,9 +931,7 @@ ZEND_API int zend_hash_quick_exists(const HashTable *ht, const char *arKey, uint uint nIndex; Bucket *p; - if (nKeyLength==0) { - return zend_hash_index_exists(ht, h); - } + ZEND_ASSERT(nKeyLength != 0); IS_CONSISTENT(ht);