gluon-web: clean up malloc() calls
This commit is contained in:
parent
f957593f26
commit
94f22e50e6
@ -80,9 +80,7 @@ static lmo_archive_t * lmo_open(const char *file)
|
||||
if ((in = open(file, O_RDONLY)) == -1)
|
||||
goto err;
|
||||
|
||||
if ((ar = (lmo_archive_t *)malloc(sizeof(*ar))) != NULL)
|
||||
{
|
||||
memset(ar, 0, sizeof(*ar));
|
||||
if ((ar = calloc(1, sizeof(*ar))) != NULL) {
|
||||
|
||||
ar->fd = in;
|
||||
ar->size = s.st_size;
|
||||
@ -140,11 +138,9 @@ int lmo_load_catalog(const char *lang, const char *dir)
|
||||
if (!dir || !(dh = opendir(dir)))
|
||||
goto err;
|
||||
|
||||
if (!(cat = malloc(sizeof(*cat))))
|
||||
if (!(cat = calloc(1, sizeof(*cat))))
|
||||
goto err;
|
||||
|
||||
memset(cat, 0, sizeof(*cat));
|
||||
|
||||
snprintf(cat->lang, sizeof(cat->lang), "%s", lang);
|
||||
snprintf(pattern, sizeof(pattern), "*.%s.lmo", lang);
|
||||
|
||||
|
@ -39,10 +39,9 @@ struct template_parser * template_open(const char *file)
|
||||
struct stat s;
|
||||
struct template_parser *parser;
|
||||
|
||||
if (!(parser = malloc(sizeof(*parser))))
|
||||
if (!(parser = calloc(1, sizeof(*parser))))
|
||||
goto err;
|
||||
|
||||
memset(parser, 0, sizeof(*parser));
|
||||
parser->fd = -1;
|
||||
parser->file = file;
|
||||
|
||||
@ -80,10 +79,9 @@ struct template_parser * template_string(const char *str, uint32_t len)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(parser = malloc(sizeof(*parser))))
|
||||
if (!(parser = calloc(1, sizeof(*parser))))
|
||||
goto err;
|
||||
|
||||
memset(parser, 0, sizeof(*parser));
|
||||
parser->fd = -1;
|
||||
|
||||
parser->size = len;
|
||||
|
@ -27,7 +27,7 @@ struct template_buffer * buf_init(int size)
|
||||
if (size <= 0)
|
||||
size = 1024;
|
||||
|
||||
buf = (struct template_buffer *)malloc(sizeof(struct template_buffer));
|
||||
buf = malloc(sizeof(*buf));
|
||||
|
||||
if (buf != NULL)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user