Change Deque_destroy to take a ptr, not ptr of ptr

This commit is contained in:
Stephen Seo 2019-01-28 15:10:04 +09:00
parent 62c1cad3da
commit a27ffa8413
3 changed files with 5 additions and 6 deletions

View file

@ -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->buf);
free(*deque); free(deque);
*deque = NULL;
} }
int UDPC_Deque_realloc(UDPC_Deque *deque, uint32_t new_size) int UDPC_Deque_realloc(UDPC_Deque *deque, uint32_t new_size)

View file

@ -20,7 +20,7 @@ UDPC_Deque* UDPC_Deque_init(uint32_t alloc_size);
/*! /*!
* Frees resources used by a UDPC_Deque * 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. * Fails if new_size is smaller than current size of Deque.

View file

@ -171,7 +171,7 @@ int main()
deque->alloc_size, deque->size, deque->head, deque->tail); deque->alloc_size, deque->size, deque->head, deque->tail);
*/ */
UDPC_Deque_destroy(&deque); UDPC_Deque_destroy(deque);
UNITTEST_REPORT() UNITTEST_REPORT()
return 0; return 0;
} }