pool: Use bool return type

Issue: 5563

This commit changes PoolDataPreAllocated to return a bool instead of an
int.
pull/9001/head
Jeff Lucovsky 3 years ago committed by Victor Julien
parent 6d7923c80b
commit 0d0c9ea07b

@ -54,14 +54,14 @@ static int PoolMemset(void *pitem, void *initdata)
/** /**
* \brief Check if data is preallocated * \brief Check if data is preallocated
* \retval 0 if not inside the prealloc'd block, 1 if inside */ * \retval false if not inside the prealloc'd block, true if inside */
static int PoolDataPreAllocated(Pool *p, void *data) static bool PoolDataPreAllocated(Pool *p, void *data)
{ {
ptrdiff_t delta = data - p->data_buffer; ptrdiff_t delta = data - p->data_buffer;
if ((delta < 0) || (delta > p->data_buffer_size)) { if ((delta < 0) || (delta > p->data_buffer_size)) {
return 0; return false;
} }
return 1; return true;
} }
/** \brief Init a Pool /** \brief Init a Pool
@ -233,7 +233,7 @@ void PoolFree(Pool *p)
p->alloc_stack = pb->next; p->alloc_stack = pb->next;
if (p->Cleanup) if (p->Cleanup)
p->Cleanup(pb->data); p->Cleanup(pb->data);
if (PoolDataPreAllocated(p, pb->data) == 0) { if (!PoolDataPreAllocated(p, pb->data)) {
if (p->Free) if (p->Free)
p->Free(pb->data); p->Free(pb->data);
else else
@ -251,7 +251,7 @@ void PoolFree(Pool *p)
if (pb->data!= NULL) { if (pb->data!= NULL) {
if (p->Cleanup) if (p->Cleanup)
p->Cleanup(pb->data); p->Cleanup(pb->data);
if (PoolDataPreAllocated(p, pb->data) == 0) { if (!PoolDataPreAllocated(p, pb->data)) {
if (p->Free) if (p->Free)
p->Free(pb->data); p->Free(pb->data);
else else
@ -350,7 +350,7 @@ void PoolReturn(Pool *p, void *data)
if (p->Cleanup != NULL) { if (p->Cleanup != NULL) {
p->Cleanup(data); p->Cleanup(data);
} }
if (PoolDataPreAllocated(p, data) == 0) { if (!PoolDataPreAllocated(p, data)) {
if (p->Free) if (p->Free)
p->Free(data); p->Free(data);
else else

Loading…
Cancel
Save