Skip to content
Snippets Groups Projects
Commit 889c4089 authored by Alexandru-Daniel BARBU's avatar Alexandru-Daniel BARBU
Browse files

Merge branch 'solutions' into 'master'

I have created the destroy function for a buffer

See merge request !2
parents 05018f2d c7eddd57
No related branches found
No related tags found
1 merge request!2I have created the destroy function for a buffer
Pipeline #90268 passed
......@@ -106,7 +106,25 @@ ssize_t ring_buffer_dequeue(so_ring_buffer_t *ring, void *data, size_t size)
void ring_buffer_destroy(so_ring_buffer_t *ring)
{
/* TODO: Implement ring_buffer_destroy */
(void) ring;
if (is_initialised)
{
pthread_mutex_lock(&init_mutex);
pthread_mutex_destroy(&ring->mutex);
sem_destroy(&ring->rb_full);
sem_destroy(&ring->rb_empty);
ring->cap = 0;
ring->len = 0;
ring->read_pos = 0;
ring->write_pos = 0;
free(ring->data);
is_initialised = 0;
pthread_mutex_unlock(&init_mutex);
}
}
void ring_buffer_stop(so_ring_buffer_t *ring)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment