From a27ffa841308b65b6619a48a6e24fd9e8eed5f3a Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Mon, 28 Jan 2019 15:10:04 +0900 Subject: [PATCH] Change Deque_destroy to take a ptr, not ptr of ptr --- src/UDPC_Deque.c | 7 +++---- src/UDPC_Deque.h | 2 +- src/test/UDPC_UnitTest.c | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/UDPC_Deque.c b/src/UDPC_Deque.c index 35a76a8..6dff813 100644 --- a/src/UDPC_Deque.c +++ b/src/UDPC_Deque.c @@ -20,11 +20,10 @@ UDPC_Deque* UDPC_Deque_init(uint32_t alloc_size) } } -void UDPC_Deque_destroy(UDPC_Deque **deque) +void UDPC_Deque_destroy(UDPC_Deque *deque) { - free((*deque)->buf); - free(*deque); - *deque = NULL; + free(deque->buf); + free(deque); } int UDPC_Deque_realloc(UDPC_Deque *deque, uint32_t new_size) diff --git a/src/UDPC_Deque.h b/src/UDPC_Deque.h index 6c8a6ca..14929f1 100644 --- a/src/UDPC_Deque.h +++ b/src/UDPC_Deque.h @@ -20,7 +20,7 @@ UDPC_Deque* UDPC_Deque_init(uint32_t alloc_size); /*! * Frees resources used by a UDPC_Deque */ -void UDPC_Deque_destroy(UDPC_Deque **deque); +void UDPC_Deque_destroy(UDPC_Deque *deque); /*! * Fails if new_size is smaller than current size of Deque. diff --git a/src/test/UDPC_UnitTest.c b/src/test/UDPC_UnitTest.c index 22be834..2090dc6 100644 --- a/src/test/UDPC_UnitTest.c +++ b/src/test/UDPC_UnitTest.c @@ -171,7 +171,7 @@ int main() deque->alloc_size, deque->size, deque->head, deque->tail); */ - UDPC_Deque_destroy(&deque); + UDPC_Deque_destroy(deque); UNITTEST_REPORT() return 0; }