Skip to content
This repository has been archived by the owner on Jun 30, 2021. It is now read-only.

Commit

Permalink
[#81] use mutex_destroy on refcount.h
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanFrench committed Mar 27, 2018
1 parent f18f946 commit bb94f81
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions refcount.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#pragma once

#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <pthread.h>

static void (* REF_free)(void *) = free;
static void (*REF_free)(void *) = free;
static void * (* REF_realloc)(void *, size_t) = realloc;
static void * (* REF_malloc)(size_t) = malloc;

Expand All @@ -25,8 +28,9 @@ static inline void
ref_init_functions(void *(*mallocf)(size_t),
void * (*callocf)(size_t, size_t),
void *(*reallocf)(void *, size_t),
void (* freef)(void *))
void (*freef)(void *))
{
(void)callocf;
REF_malloc = mallocf;
REF_realloc = reallocf;
REF_free = freef;
Expand Down Expand Up @@ -79,6 +83,7 @@ ref_free(void * buf)
if (--refc->count == 0)
{
pthread_mutex_unlock(&refc->mux);
pthread_mutex_destroy(&refc->mux);
return REF_free(refc);
}
});
Expand Down

0 comments on commit bb94f81

Please sign in to comment.