1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Add ts_allocate_dtor, use ts_allocate_[cd]tor where appropiate.

This commit is contained in:
Sascha Schumann
1999-12-05 16:21:37 +00:00
parent 45f9527518
commit e5d956dbac
2 changed files with 9 additions and 8 deletions

View File

@@ -34,8 +34,8 @@ struct _tsrm_tls_entry {
typedef struct {
size_t size;
void (*ctor)(void *resource);
void (*dtor)(void *resource);
ts_allocate_ctor ctor;
ts_allocate_dtor dtor;
} tsrm_resource_type;
@@ -89,7 +89,7 @@ TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debu
/* Shutdown TSRM (call once for the entire process) */
TSRM_API void tsrm_shutdown()
TSRM_API void tsrm_shutdown(void)
{
int i;
@@ -120,7 +120,7 @@ TSRM_API void tsrm_shutdown()
/* allocates a new thread-safe-resource id */
TSRM_API ts_rsrc_id ts_allocate_id(size_t size, void (*ctor)(void *resource), void (*dtor)(void *resource))
TSRM_API ts_rsrc_id ts_allocate_id(size_t size, ts_allocate_ctor ctor, ts_allocate_dtor dtor)
{
ts_rsrc_id new_id;
int i;
@@ -245,7 +245,7 @@ void *ts_resource(ts_rsrc_id id)
/* frees all resources allocated for the current thread */
void ts_free_thread()
void ts_free_thread(void)
{
THREAD_T thread_id = tsrm_thread_id();
int hash_value;

View File

@@ -60,6 +60,7 @@ typedef int ts_rsrc_id;
#endif
typedef void (*ts_allocate_ctor)(void *);
typedef void (*ts_allocate_dtor)(void *);
#define THREAD_HASH_OF(thr,ts) (unsigned long)thr%(unsigned long)ts
@@ -69,16 +70,16 @@ extern "C" {
/* startup/shutdown */
TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debug_status);
TSRM_API void tsrm_shutdown();
TSRM_API void tsrm_shutdown(void);
/* allocates a new thread-safe-resource id */
TSRM_API ts_rsrc_id ts_allocate_id(size_t size, ts_allocate_ctor ctor, void (*dtor)(void *resource));
TSRM_API ts_rsrc_id ts_allocate_id(size_t size, ts_allocate_ctor ctor, ts_allocate_dtor dtor);
/* fetches the requested resource for the current thread */
TSRM_API void *ts_resource(ts_rsrc_id id);
/* frees all resources allocated for the current thread */
TSRM_API void ts_free_thread();
TSRM_API void ts_free_thread(void);
/* deallocates all occurrences of a given id */
TSRM_API void ts_free_id(ts_rsrc_id id);