Use malloc instead of calloc when possible
This commit is contained in:
parent
74b3b505c9
commit
7cac61e5eb
|
@ -78,7 +78,16 @@ bool file_list_insert(file_list_t *list,
|
||||||
for (i = (unsigned)list->size; i > (int)idx; i--)
|
for (i = (unsigned)list->size; i > (int)idx; i--)
|
||||||
{
|
{
|
||||||
struct item_file *copy = (struct item_file*)
|
struct item_file *copy = (struct item_file*)
|
||||||
calloc(1, sizeof(struct item_file));
|
malloc(sizeof(struct item_file));
|
||||||
|
|
||||||
|
copy->path = NULL;
|
||||||
|
copy->label = NULL;
|
||||||
|
copy->alt = NULL;
|
||||||
|
copy->type = 0;
|
||||||
|
copy->directory_ptr = 0;
|
||||||
|
copy->entry_idx = 0;
|
||||||
|
copy->userdata = NULL;
|
||||||
|
copy->actiondata = NULL;
|
||||||
|
|
||||||
memcpy(copy, &list->list[i-1], sizeof(struct item_file));
|
memcpy(copy, &list->list[i-1], sizeof(struct item_file));
|
||||||
|
|
||||||
|
|
|
@ -95,11 +95,15 @@ static bool string_list_capacity(struct string_list *list, size_t cap)
|
||||||
struct string_list *string_list_new(void)
|
struct string_list *string_list_new(void)
|
||||||
{
|
{
|
||||||
struct string_list *list = (struct string_list*)
|
struct string_list *list = (struct string_list*)
|
||||||
calloc(1, sizeof(*list));
|
malloc(sizeof(*list));
|
||||||
|
|
||||||
if (!list)
|
if (!list)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
list->elems = NULL;
|
||||||
|
list->size = 0;
|
||||||
|
list->cap = 0;
|
||||||
|
|
||||||
if (!string_list_capacity(list, 32))
|
if (!string_list_capacity(list, 32))
|
||||||
{
|
{
|
||||||
string_list_free(list);
|
string_list_free(list);
|
||||||
|
@ -376,19 +380,22 @@ struct string_list *string_list_clone(
|
||||||
const struct string_list *src)
|
const struct string_list *src)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
struct string_list_elem *elems = NULL;
|
struct string_list_elem
|
||||||
struct string_list *dest = (struct string_list*)
|
*elems = NULL;
|
||||||
calloc(1, sizeof(struct string_list));
|
struct string_list
|
||||||
|
*dest = (struct string_list*)
|
||||||
|
malloc(sizeof(struct string_list));
|
||||||
|
|
||||||
if (!dest)
|
if (!dest)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
dest->size = src->size;
|
dest->elems = NULL;
|
||||||
dest->cap = src->cap;
|
dest->size = src->size;
|
||||||
|
dest->cap = src->cap;
|
||||||
if (dest->cap < dest->size)
|
if (dest->cap < dest->size)
|
||||||
dest->cap = dest->size;
|
dest->cap = dest->size;
|
||||||
|
|
||||||
elems = (struct string_list_elem*)
|
elems = (struct string_list_elem*)
|
||||||
calloc(dest->cap, sizeof(struct string_list_elem));
|
calloc(dest->cap, sizeof(struct string_list_elem));
|
||||||
|
|
||||||
if (!elems)
|
if (!elems)
|
||||||
|
|
Loading…
Reference in New Issue