1 /* 2 +----------------------------------------------------------------------+ 3 | Zend Engine | 4 +----------------------------------------------------------------------+ 5 | Copyright (c) 1998-2014 Zend Technologies Ltd. (http://www.zend.com) | 6 +----------------------------------------------------------------------+ 7 | This source file is subject to version 2.00 of the Zend license, | 8 | that is bundled with this package in the file LICENSE, and is | 9 | available through the world-wide-web at the following url: | 10 | http://www.zend.com/license/2_00.txt. | 11 | If you did not receive a copy of the Zend license and are unable to | 12 | obtain it through the world-wide-web, please send a note to | 13 | license@zend.com so we can mail you a copy immediately. | 14 +----------------------------------------------------------------------+ 15 | Authors: Dmitry Stogov <dmitry@zend.com> | 16 +----------------------------------------------------------------------+ 17 */ 18 19 /* $Id: $ */ 20 21 #ifndef ZEND_STRING_H 22 #define ZEND_STRING_H 23 24 #include "zend.h" 25 26 BEGIN_EXTERN_C() 27 ZEND_API extern const char *(*zend_new_interned_string)(const char *str, int len, int free_src TSRMLS_DC); 28 ZEND_API extern void (*zend_interned_strings_snapshot)(TSRMLS_D); 29 ZEND_API extern void (*zend_interned_strings_restore)(TSRMLS_D); 30 31 void zend_interned_strings_init(TSRMLS_D); 32 void zend_interned_strings_dtor(TSRMLS_D); 33 END_EXTERN_C() 34 35 #ifndef ZTS 36 37 #define IS_INTERNED(s) \ 38 (((s) >= CG(interned_strings_start)) && ((s) < CG(interned_strings_end))) 39 40 #else 41 42 #define IS_INTERNED(s) \ 43 (0) 44 45 #endif 46 47 #define INTERNED_LEN(s) \ 48 (((Bucket*)(((char*)(s))-sizeof(Bucket)))->nKeyLength) 49 50 #define INTERNED_HASH(s) \ 51 (((Bucket*)(((char*)(s))-sizeof(Bucket)))->h) 52 53 #define str_efree(s) do { \ 54 if (!IS_INTERNED(s)) { \ 55 efree((char*)s); \ 56 } \ 57 } while (0) 58 59 #define str_free(s) do { \ 60 if (!IS_INTERNED(s)) { \ 61 free((char*)s); \ 62 } \ 63 } while (0) 64 65 #endif /* ZEND_STRING_H */ 66 67 /* 68 * Local variables: 69 * tab-width: 4 70 * c-basic-offset: 4 71 * indent-tabs-mode: t 72 * End: 73 */ 74