Changeset 95 for trunk/utils.c
- Timestamp:
- 07/16/2006 11:07:57 AM (2 years ago)
- Files:
-
- 1 modified
-
trunk/utils.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/utils.c
r88 r95 265 265 #endif 266 266 267 #ifdef HAVE_XCACHE_CONSTANT 268 void xc_install_constant(char *filename, zend_constant *constant, zend_uchar type, void *key, uint len TSRMLS_DC) /* {{{ */ 269 { 270 if (zend_u_hash_add(EG(zend_constants), type, key, len, 271 constant, sizeof(zend_constant), 272 NULL 273 ) == FAILURE) { 274 CG(in_compilation) = 1; 275 CG(compiled_filename) = filename; 276 CG(zend_lineno) = 0; 277 zend_error(E_NOTICE, "Constant %s already defined", key); 278 free(constant->name); 279 if (!(constant->flags & CONST_PERSISTENT)) { 280 zval_dtor(&constant->value); 281 } 282 } 283 } 284 /* }}} */ 285 #endif 267 286 void xc_install_function(char *filename, zend_function *func, zend_uchar type, void *key, uint len TSRMLS_DC) /* {{{ */ 268 287 { … … 316 335 #define OG(x) (sandbox->orig_##x) 317 336 /* }}} */ 337 #ifdef HAVE_XCACHE_CONSTANT 338 static void xc_constant_copy_ctor(zend_constant *c) /* {{{ */ 339 { 340 c->name = zend_strndup(c->name, c->name_len - 1); 341 if (!(c->flags & CONST_PERSISTENT)) { 342 zval_copy_ctor(&c->value); 343 } 344 } 345 /* }}} */ 346 #endif 318 347 xc_sandbox_t *xc_sandbox_init(xc_sandbox_t *sandbox, char *filename TSRMLS_DC) /* {{{ */ 319 348 { … … 325 354 sandbox->alloc = 1; 326 355 } 356 327 357 memcpy(&OG(included_files), &EG(included_files), sizeof(EG(included_files))); 328 358 memcpy(&OG(open_files), &CG(open_files), sizeof(CG(open_files))); 359 360 #ifdef HAVE_XCACHE_CONSTANT 361 OG(zend_constants) = EG(zend_constants); 362 EG(zend_constants) = &TG(zend_constants); 363 #endif 329 364 330 365 OG(function_table) = CG(function_table); … … 342 377 zend_llist_init(TG(open_files), sizeof(zend_file_handle), (void (*)(void *)) zend_file_handle_dtor, 0); 343 378 zend_hash_init_ex(TG(included_files), 5, NULL, NULL, 0, 1); 379 #ifdef HAVE_XCACHE_CONSTANT 380 zend_hash_init_ex(&TG(zend_constants), 20, NULL, ZEND_CONSTANT_DTOR, 1, 0); 381 #endif 344 382 zend_hash_init_ex(&TG(function_table), 128, NULL, ZEND_FUNCTION_DTOR, 0, 0); 345 383 zend_hash_init_ex(&TG(class_table), 16, NULL, ZEND_CLASS_DTOR, 0, 0); … … 356 394 zend_llist_position lpos; 357 395 zend_file_handle *handle; 396 397 #ifdef HAVE_XCACHE_CONSTANT 398 b = TG(zend_constants).pListHead; 399 /* install constants */ 400 while (b != NULL) { 401 zend_constant *c = (zend_constant*) b->pData; 402 xc_install_constant(sandbox->filename, c, 403 BUCKET_KEY_TYPE(b), BUCKET_KEY(b), b->nKeyLength TSRMLS_CC); 404 b = b->pListNext; 405 } 406 #endif 358 407 359 408 b = TG(function_table).pListHead; … … 386 435 { 387 436 /* restore first first install function/class */ 437 #ifdef HAVE_XCACHE_CONSTANT 438 EG(zend_constants) = OG(zend_constants); 439 #endif 388 440 CG(function_table) = OG(function_table); 389 441 CG(class_table) = OG(class_table); … … 394 446 395 447 /* no free as it's installed */ 448 #ifdef HAVE_XCACHE_CONSTANT 449 TG(zend_constants).pDestructor = NULL; 450 #endif 396 451 TG(function_table).pDestructor = NULL; 397 452 TG(class_table).pDestructor = NULL; … … 400 455 401 456 /* destroy all the tmp */ 457 #ifdef HAVE_XCACHE_CONSTANT 458 zend_hash_destroy(&TG(zend_constants)); 459 #endif 402 460 zend_hash_destroy(&TG(function_table)); 403 461 zend_hash_destroy(&TG(class_table));

