X-Git-Url: http://git.hcoop.net/bpt/guile.git/blobdiff_plain/a06e3a75b298d2335d134cfec97ee893b29aea33..9bc6fb0a7d91ae9a6c57cedb76022043db413ba5:/libguile/coop-threads.c diff --git a/libguile/coop-threads.c b/libguile/coop-threads.c index d126f67f6..a3f4018e0 100644 --- a/libguile/coop-threads.c +++ b/libguile/coop-threads.c @@ -257,9 +257,8 @@ scm_call_with_new_thread (SCM argl) /* Allocate thread locals. */ root = scm_make_root (scm_root->handle); /* Make thread. */ - SCM_NEWCELL (thread); + thread = scm_cell (scm_tc16_thread, 0); SCM_DEFER_INTS; - SCM_SETCAR (thread, scm_tc16_thread); argl = scm_cons (thread, argl); /* Note that we couldn't pass a pointer to argl as data since the argl variable may not exist in memory when the thread starts. */ @@ -325,7 +324,7 @@ c_launch_thread (void *p) data, (SCM_STACKITEM *) &thread); scm_thread_count--; - scm_must_free ((char *) data); + free ((char *) data); } SCM @@ -335,8 +334,7 @@ scm_spawn_thread (scm_t_catch_body body, void *body_data, SCM thread; coop_t *t; SCM root, old_winds; - c_launch_data *data = (c_launch_data *) scm_must_malloc (sizeof (*data), - "scm_spawn_thread"); + c_launch_data *data = (c_launch_data *) scm_malloc (sizeof (*data)); /* Unwind wind chain. */ old_winds = scm_dynwinds; @@ -345,9 +343,8 @@ scm_spawn_thread (scm_t_catch_body body, void *body_data, /* Allocate thread locals. */ root = scm_make_root (scm_root->handle); /* Make thread. */ - SCM_NEWCELL (thread); + thread = scm_cell (scm_tc16_thread, 0); SCM_DEFER_INTS; - SCM_SETCAR (thread, scm_tc16_thread); data->u.thread = thread; data->body = body; @@ -416,11 +413,8 @@ scm_single_thread_p (void) SCM scm_make_mutex (void) { - SCM m; - coop_m *data = (coop_m *) scm_must_malloc (sizeof (coop_m), "mutex"); - - SCM_NEWSMOB (m, scm_tc16_mutex, (scm_t_bits) data); - coop_mutex_init (data); + SCM m = scm_make_smob (scm_tc16_mutex); + coop_mutex_init (SCM_MUTEX_DATA (m)); return m; } @@ -448,9 +442,7 @@ scm_unlock_mutex (SCM m) SCM scm_make_condition_variable (void) { - SCM c; - coop_c *data = (coop_c *) scm_must_malloc (sizeof (coop_c), "condvar"); - SCM_NEWSMOB (c, scm_tc16_condvar, (scm_t_bits) data); + SCM c = scm_make_smob (scm_tc16_condvar); coop_condition_variable_init (SCM_CONDVAR_DATA (c)); return c; }