Skip to content

Commit e5d956d

Browse files
author
Sascha Schumann
committed
Add ts_allocate_dtor, use ts_allocate_[cd]tor where appropiate.
1 parent 45f9527 commit e5d956d

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

TSRM/TSRM.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ struct _tsrm_tls_entry {
3434

3535
typedef struct {
3636
size_t size;
37-
void (*ctor)(void *resource);
38-
void (*dtor)(void *resource);
37+
ts_allocate_ctor ctor;
38+
ts_allocate_dtor dtor;
3939
} tsrm_resource_type;
4040

4141

@@ -89,7 +89,7 @@ TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debu
8989

9090

9191
/* Shutdown TSRM (call once for the entire process) */
92-
TSRM_API void tsrm_shutdown()
92+
TSRM_API void tsrm_shutdown(void)
9393
{
9494
int i;
9595

@@ -120,7 +120,7 @@ TSRM_API void tsrm_shutdown()
120120

121121

122122
/* allocates a new thread-safe-resource id */
123-
TSRM_API ts_rsrc_id ts_allocate_id(size_t size, void (*ctor)(void *resource), void (*dtor)(void *resource))
123+
TSRM_API ts_rsrc_id ts_allocate_id(size_t size, ts_allocate_ctor ctor, ts_allocate_dtor dtor)
124124
{
125125
ts_rsrc_id new_id;
126126
int i;
@@ -245,7 +245,7 @@ void *ts_resource(ts_rsrc_id id)
245245

246246

247247
/* frees all resources allocated for the current thread */
248-
void ts_free_thread()
248+
void ts_free_thread(void)
249249
{
250250
THREAD_T thread_id = tsrm_thread_id();
251251
int hash_value;

TSRM/TSRM.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ typedef int ts_rsrc_id;
6060
#endif
6161

6262
typedef void (*ts_allocate_ctor)(void *);
63+
typedef void (*ts_allocate_dtor)(void *);
6364

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

@@ -69,16 +70,16 @@ extern "C" {
6970

7071
/* startup/shutdown */
7172
TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debug_status);
72-
TSRM_API void tsrm_shutdown();
73+
TSRM_API void tsrm_shutdown(void);
7374

7475
/* allocates a new thread-safe-resource id */
75-
TSRM_API ts_rsrc_id ts_allocate_id(size_t size, ts_allocate_ctor ctor, void (*dtor)(void *resource));
76+
TSRM_API ts_rsrc_id ts_allocate_id(size_t size, ts_allocate_ctor ctor, ts_allocate_dtor dtor);
7677

7778
/* fetches the requested resource for the current thread */
7879
TSRM_API void *ts_resource(ts_rsrc_id id);
7980

8081
/* frees all resources allocated for the current thread */
81-
TSRM_API void ts_free_thread();
82+
TSRM_API void ts_free_thread(void);
8283

8384
/* deallocates all occurrences of a given id */
8485
TSRM_API void ts_free_id(ts_rsrc_id id);

0 commit comments

Comments
 (0)