Skip to content

Commit

Permalink
removed the extra tsrm pointer passed to ctor/dtor
Browse files Browse the repository at this point in the history
  • Loading branch information
weltling committed Dec 16, 2014
1 parent bd76a50 commit 64b423d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions TSRM/TSRM.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ TSRM_API void tsrm_shutdown(void)
for (j=0; j<p->count; j++) {
if (p->storage[j]) {
if (resource_types_table && !resource_types_table[j].done && resource_types_table[j].dtor) {
resource_types_table[j].dtor(p->storage[j], &p->storage);
resource_types_table[j].dtor(p->storage[j]);
}
free(p->storage[j]);
}
Expand Down Expand Up @@ -256,7 +256,7 @@ TSRM_API ts_rsrc_id ts_allocate_id(ts_rsrc_id *rsrc_id, size_t size, ts_allocate
for (j=p->count; j<id_count; j++) {
p->storage[j] = (void *) malloc(resource_types_table[j].size);
if (resource_types_table[j].ctor) {
resource_types_table[j].ctor(p->storage[j], &p->storage);
resource_types_table[j].ctor(p->storage[j]);
}
}
p->count = id_count;
Expand Down Expand Up @@ -295,7 +295,7 @@ static void allocate_new_resource(tsrm_tls_entry **thread_resources_ptr, THREAD_
{
(*thread_resources_ptr)->storage[i] = (void *) malloc(resource_types_table[i].size);
if (resource_types_table[i].ctor) {
resource_types_table[i].ctor((*thread_resources_ptr)->storage[i], &(*thread_resources_ptr)->storage);
resource_types_table[i].ctor((*thread_resources_ptr)->storage[i]);
}
}
}
Expand Down Expand Up @@ -394,7 +394,7 @@ void tsrm_free_interpreter_context(void *context)

for (i=0; i<thread_resources->count; i++) {
if (resource_types_table[i].dtor) {
resource_types_table[i].dtor(thread_resources->storage[i], &thread_resources->storage);
resource_types_table[i].dtor(thread_resources->storage[i]);
}
}
for (i=0; i<thread_resources->count; i++) {
Expand Down Expand Up @@ -459,7 +459,7 @@ void ts_free_thread(void)
if (thread_resources->thread_id == thread_id) {
for (i=0; i<thread_resources->count; i++) {
if (resource_types_table[i].dtor) {
resource_types_table[i].dtor(thread_resources->storage[i], &thread_resources->storage);
resource_types_table[i].dtor(thread_resources->storage[i]);
}
}
for (i=0; i<thread_resources->count; i++) {
Expand Down Expand Up @@ -501,7 +501,7 @@ void ts_free_worker_threads(void)
if (thread_resources->thread_id != thread_id) {
for (i=0; i<thread_resources->count; i++) {
if (resource_types_table[i].dtor) {
resource_types_table[i].dtor(thread_resources->storage[i], &thread_resources->storage);
resource_types_table[i].dtor(thread_resources->storage[i]);
}
}
for (i=0; i<thread_resources->count; i++) {
Expand Down Expand Up @@ -547,7 +547,7 @@ void ts_free_id(ts_rsrc_id id)
while (p) {
if (p->count > j && p->storage[j]) {
if (resource_types_table && resource_types_table[j].dtor) {
resource_types_table[j].dtor(p->storage[j], &p->storage);
resource_types_table[j].dtor(p->storage[j]);
}
free(p->storage[j]);
p->storage[j] = NULL;
Expand Down
4 changes: 2 additions & 2 deletions TSRM/TSRM.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ typedef struct {
#include <signal.h>
#endif

typedef void (*ts_allocate_ctor)(void *, void ***);
typedef void (*ts_allocate_dtor)(void *, void ***);
typedef void (*ts_allocate_ctor)(void *);
typedef void (*ts_allocate_dtor)(void *);

#define THREAD_HASH_OF(thr,ts) (unsigned long)thr%(unsigned long)ts

Expand Down

0 comments on commit 64b423d

Please sign in to comment.