Skip to content

Commit

Permalink
no leaking that threadbuffer memory
Browse files Browse the repository at this point in the history
  • Loading branch information
wiedehopf committed Aug 20, 2022
1 parent dd9bca8 commit bd94ae1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 1 addition & 3 deletions threadpool.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,7 @@ void threadpool_destroy(threadpool_t *pool)
pthread_join(thread->pthread, NULL);

for (uint32_t k = 0; k < thread->user_buffers.buffer_count; k++) {
free(thread->user_buffers.buffers[k].buf);
thread->user_buffers.buffers[k].buf = NULL;
thread->user_buffers.buffers[k].size = 0;
free_threadpool_buffer(&thread->user_buffers.buffers[k]);
}
free(thread->user_buffers.buffers);
}
Expand Down
2 changes: 2 additions & 0 deletions threadpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ typedef struct {
#endif
} threadpool_buffer_t;

// this function is called when destroying a threadpool with buffers
// in case you're using the threadpool_buffer_t yourself, you can use this to free the buffers in it
void free_threadpool_buffer(threadpool_buffer_t *buffer);

typedef struct {
Expand Down

0 comments on commit bd94ae1

Please sign in to comment.