(libretro-common) Use malloc instead of calloc when possible

This commit is contained in:
twinaphex 2020-06-24 17:35:02 +02:00
parent 53f3199652
commit 3a4af3149b
2 changed files with 16 additions and 13 deletions

View File

@ -28,11 +28,13 @@
fifo_buffer_t *fifo_new(size_t size)
{
uint8_t *buffer = NULL;
fifo_buffer_t *buf = (fifo_buffer_t*)calloc(1, sizeof(*buf));
fifo_buffer_t *buf = (fifo_buffer_t*)malloc(sizeof(*buf));
if (!buf)
return NULL;
buf->first = 0;
buf->end = 0;
buffer = (uint8_t*)calloc(1, size + 1);
if (!buffer)

View File

@ -59,12 +59,13 @@ struct msg_queue
msg_queue_t *msg_queue_new(size_t size)
{
struct queue_elem **elems = NULL;
msg_queue_t *queue = (msg_queue_t*)calloc(1, sizeof(*queue));
msg_queue_t *queue = (msg_queue_t*)malloc(sizeof(*queue));
if (!queue)
return NULL;
queue->size = size + 1;
queue->tmp_msg = NULL;
elems = (struct queue_elem**)calloc(queue->size,
sizeof(struct queue_elem*));
@ -119,13 +120,13 @@ void msg_queue_push(msg_queue_t *queue, const char *msg,
if (!queue || queue->ptr >= queue->size)
return;
new_elem = (struct queue_elem*)
calloc(1, sizeof(struct queue_elem));
new_elem = (struct queue_elem*)malloc(
sizeof(struct queue_elem));
if (!new_elem)
return;
new_elem->prio = prio;
new_elem->duration = duration;
new_elem->prio = prio;
new_elem->msg = msg ? strdup(msg) : NULL;
new_elem->title = title ? strdup(title) : NULL;
new_elem->icon = icon;