From 5be8dd9712f80a957db14e88f2390c65bece14fc Mon Sep 17 00:00:00 2001 From: Zeev Suraski Date: Fri, 23 Apr 1999 11:00:02 +0000 Subject: [PATCH] License --- TSRM/TSRM.c | 27 +++++++++++++++++++++++++-- TSRM/TSRM.h | 16 ++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/TSRM/TSRM.c b/TSRM/TSRM.c index 6ffc2e478d..50928562e4 100644 --- a/TSRM/TSRM.c +++ b/TSRM/TSRM.c @@ -1,3 +1,19 @@ +/* + +----------------------------------------------------------------------+ + | Thread Safe Resource Manager | + +----------------------------------------------------------------------+ + | Copyright (c) 1998, 1999 Zeev Suraski | + +----------------------------------------------------------------------+ + | This source file is subject to the Zend license, that is bundled | + | with this package in the file LICENSE. If you did not receive a | + | copy of the Zend license, please mail us at zend@zend.com so we can | + | send you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Zeev Suraski | + +----------------------------------------------------------------------+ +*/ + + #include "TSRM.h" #include @@ -129,6 +145,9 @@ TSRM_FUNC ts_rsrc_id ts_allocate_id(size_t size, void (*ctor)(void *resource), v p->storage = realloc(p->storage, sizeof(void *)*id_count); for (j=p->count; jstorage[j] = (void *) malloc(resource_types_table[j].size); + if (resource_types_table[j].ctor) { + resource_types_table[j].ctor(p->storage[j]); + } } p->count = id_count; } @@ -153,7 +172,9 @@ static void allocate_new_resource(tsrm_tls_entry **thread_resources_ptr, THREAD_ (*thread_resources_ptr)->next = NULL; for (i=0; istorage[i] = (void *) malloc(resource_types_table[i].size); - resource_types_table[i].ctor((*thread_resources_ptr)->storage[i]); + if (resource_types_table[i].ctor) { + resource_types_table[i].ctor((*thread_resources_ptr)->storage[i]); + } } } @@ -216,7 +237,9 @@ void ts_free_thread() int i; for (i=0; icount; i++) { - resource_types_table[i].dtor(thread_resources->storage[i]); + if (resource_types_table[i].dtor) { + resource_types_table[i].dtor(thread_resources->storage[i]); + } free(thread_resources->storage[i]); } free(thread_resources->storage); diff --git a/TSRM/TSRM.h b/TSRM/TSRM.h index 3591dc2b04..aec84fe7e6 100644 --- a/TSRM/TSRM.h +++ b/TSRM/TSRM.h @@ -1,3 +1,19 @@ +/* + +----------------------------------------------------------------------+ + | Thread Safe Resource Manager | + +----------------------------------------------------------------------+ + | Copyright (c) 1998, 1999 Zeev Suraski | + +----------------------------------------------------------------------+ + | This source file is subject to the Zend license, that is bundled | + | with this package in the file LICENSE. If you did not receive a | + | copy of the Zend license, please mail us at zend@zend.com so we can | + | send you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Zeev Suraski | + +----------------------------------------------------------------------+ +*/ + + #ifndef _TSRM_H #define _TSRM_H -- 2.50.1