avoid usage of goto`
This commit is contained in:
@@ -54,7 +54,7 @@ bool CircQueueCreate(CIRC_QUEUE **q, uint32_t queueCapacity)
|
||||
ASSERT(q != NULL);
|
||||
CIRC_QUEUE *queue;
|
||||
queue = malloc(sizeof(CIRC_QUEUE));
|
||||
if (!queue)
|
||||
if (queue == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -65,16 +65,14 @@ bool CircQueueCreate(CIRC_QUEUE **q, uint32_t queueCapacity)
|
||||
queue->data = malloc(queueCapacity * sizeof(void *));
|
||||
if (queue->data == NULL)
|
||||
{
|
||||
goto error;
|
||||
free(queue);
|
||||
return false;
|
||||
}
|
||||
queue->bounds = queueCapacity;
|
||||
queue->nelts = 0;
|
||||
queue->in = 0;
|
||||
queue->out = 0;
|
||||
return true;
|
||||
error:
|
||||
free(queue);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user