diff options
author | rpj <rpj> | 2001-10-26 00:59:36 +0000 |
---|---|---|
committer | rpj <rpj> | 2001-10-26 00:59:36 +0000 |
commit | 104d1669a344de413ea4c7f1106fcf4a5d95b610 (patch) | |
tree | f60879376166e1eb13b98e57cb07c154f8d2be8d /semaphore.c | |
parent | 70451597bca186f31d4a69aec0ae940fe90e3d56 (diff) |
semaphore.c (sem_init): somehow when sem_t reverted to an opaque struct
the calloc NULL check was left in the conditionally included section.
(sem_destroy): Likewise, the calloced sem_t wasn't being freed.
Diffstat (limited to 'semaphore.c')
-rw-r--r-- | semaphore.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/semaphore.c b/semaphore.c index 1e23285..0dc9ed9 100644 --- a/semaphore.c +++ b/semaphore.c @@ -90,14 +90,16 @@ sem_init (sem_t * sem, int pshared, unsigned int value) } else { - s = (sem_t) calloc (1, sizeof (*s)); -#ifdef NEED_SEM + s = (sem_t) calloc (1, sizeof (*s)); if (NULL == s) { result = ENOMEM; } + +#ifdef NEED_SEM + else { s->value = value; @@ -184,7 +186,7 @@ sem_destroy (sem_t * sem) } else { - s = *sem; + s = *sem; *sem = NULL; #ifdef NEED_SEM @@ -197,7 +199,6 @@ sem_destroy (sem_t * sem) else { DeleteCriticalSection(&s->sem_lock_cs); - free(s); } #else /* NEED_SEM */ @@ -218,6 +219,8 @@ sem_destroy (sem_t * sem) return -1; } + free(s); + return 0; } /* sem_destroy */ |