mem allocs guaranteed now... they are wrapped and errors handled centrally
SVN revision: 7018
This commit is contained in:
parent
228f197d2b
commit
598dd0b60f
|
@ -30,6 +30,7 @@ edje_cc.c \
|
|||
edje_cc.h \
|
||||
edje_cc_out.c \
|
||||
edje_cc_parse.c \
|
||||
edje_cc_mem.c \
|
||||
edje_cc_handlers.c
|
||||
|
||||
edje_cc_LDADD = \
|
||||
|
|
|
@ -56,16 +56,11 @@ main(int argc, char **argv)
|
|||
exit(-1);
|
||||
}
|
||||
|
||||
edje_file = calloc(1, sizeof(Edje_File));
|
||||
if (!edje_file)
|
||||
{
|
||||
fprintf(stderr, "%s: Error. memory allocation of %i bytes failed. %s\n",
|
||||
progname, sizeof(Edje_File), strerror(errno));
|
||||
exit(-1);
|
||||
}
|
||||
edje_file = mem_alloc(SZ(Edje_File));
|
||||
|
||||
data_setup();
|
||||
compile();
|
||||
data_write();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <sys/stat.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
/* types */
|
||||
typedef struct _New_Object_Handler New_Object_Handler;
|
||||
typedef struct _New_Statement_Handler New_Statement_Handler;
|
||||
|
||||
|
@ -32,12 +33,11 @@ struct _New_Statement_Handler
|
|||
void (*func)(void);
|
||||
};
|
||||
|
||||
/* global fn calls */
|
||||
void data_setup(void);
|
||||
void data_write(void);
|
||||
void compile(void);
|
||||
int object_handler_num(void);
|
||||
int statement_handler_num(void);
|
||||
|
||||
void compile(void);
|
||||
char *parse_str(int n);
|
||||
int parse_enum(int n, ...);
|
||||
int parse_int(int n);
|
||||
|
@ -45,6 +45,14 @@ int parse_int_range(int n, int f, int t);
|
|||
double parse_float(int n);
|
||||
double parse_float_range(int n, int f, int t);
|
||||
|
||||
int object_handler_num(void);
|
||||
int statement_handler_num(void);
|
||||
|
||||
void *mem_alloc(size_t size);
|
||||
char *mem_strdup(const char *s);
|
||||
#define SZ sizeof
|
||||
|
||||
/* global vars */
|
||||
extern Evas_List *img_dirs;
|
||||
extern char *file_in;
|
||||
extern char *file_out;
|
||||
|
|
|
@ -5,6 +5,12 @@ static void ob_images_image(void);
|
|||
static void st_images_image(void);
|
||||
|
||||
static void ob_collections(void);
|
||||
static void ob_collections_group(void);
|
||||
static void ob_collections_group_parts(void);
|
||||
static void ob_collections_group_parts_part(void);
|
||||
static void ob_collections_group_parts_part_description(void);
|
||||
static void ob_collections_group_programs(void);
|
||||
static void ob_collections_group_programs_program(void);
|
||||
|
||||
/*****/
|
||||
|
||||
|
@ -13,23 +19,23 @@ New_Object_Handler object_handlers[] =
|
|||
{"images", ob_images},
|
||||
{"images.image", ob_images_image},
|
||||
{"collections", ob_collections},
|
||||
{"collections.group", NULL},
|
||||
{"collections.group", ob_collections_group},
|
||||
{"collections.group.name", NULL},
|
||||
{"collections.group.parts", NULL},
|
||||
{"collections.group.parts.part", NULL},
|
||||
{"collections.group.parts", ob_collections_group_parts},
|
||||
{"collections.group.parts.part", ob_collections_group_parts_part},
|
||||
{"collections.group.parts.part.name", NULL},
|
||||
{"collections.group.parts.part.type", NULL},
|
||||
{"collections.group.parts.part.mouse_events", NULL},
|
||||
{"collections.group.parts.part.color_class", NULL},
|
||||
{"collections.group.parts.part.description", NULL},
|
||||
{"collections.group.parts.part.description", ob_collections_group_parts_part_description},
|
||||
{"collections.group.parts.part.description.state", NULL},
|
||||
{"collections.group.parts.part.description.visible", NULL},
|
||||
{"collections.group.parts.part.description.dragable", NULL},
|
||||
{"collections.group.parts.part.description.dragable.x", NULL},
|
||||
{"collections.group.parts.part.description.dragable.y", NULL},
|
||||
{"collections.group.parts.part.description.dragable.confine", NULL},
|
||||
{"collections.group.programs", NULL},
|
||||
{"collections.group.programs.program", NULL}
|
||||
{"collections.group.programs", ob_collections_group_programs},
|
||||
{"collections.group.programs.program", ob_collections_group_programs_program}
|
||||
};
|
||||
|
||||
New_Statement_Handler statement_handlers[] =
|
||||
|
@ -66,13 +72,7 @@ statement_handler_num(void)
|
|||
static void
|
||||
ob_images(void)
|
||||
{
|
||||
edje_file->image_dir = calloc(1, sizeof(Edje_Image_Directory));
|
||||
if (!edje_file->image_dir)
|
||||
{
|
||||
fprintf(stderr, "%s: Error. memory allocation of %i bytes failed. %s\n",
|
||||
progname, sizeof(Edje_Image_Directory), strerror(errno));
|
||||
exit(-1);
|
||||
}
|
||||
edje_file->image_dir = mem_alloc(SZ(Edje_Image_Directory));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -125,5 +125,40 @@ st_images_image(void)
|
|||
|
||||
static void
|
||||
ob_collections(void)
|
||||
{
|
||||
edje_file->collection_dir = mem_alloc(SZ(Edje_Part_Collection_Directory));
|
||||
}
|
||||
|
||||
static void
|
||||
ob_collections_group(void)
|
||||
{
|
||||
Edje_Part_Collection_Directory_Entry *de;
|
||||
|
||||
de = mem_alloc(SZ(Edje_Part_Collection_Directory_Entry));
|
||||
}
|
||||
|
||||
static void
|
||||
ob_collections_group_parts(void)
|
||||
{
|
||||
Edje_Part_Collection *pc;
|
||||
}
|
||||
|
||||
static void
|
||||
ob_collections_group_parts_part(void)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
ob_collections_group_parts_part_description(void)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
ob_collections_group_programs(void)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
ob_collections_group_programs_program(void)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
#include "edje_cc.h"
|
||||
|
||||
void *
|
||||
mem_alloc(size_t size)
|
||||
{
|
||||
void *mem;
|
||||
|
||||
mem = calloc(1, size);
|
||||
if (mem) return mem;
|
||||
fprintf(stderr, "%s: Error. %s:%i memory allocation of %i bytes failed. %s\n",
|
||||
progname, file_in, line, size, strerror(errno));
|
||||
exit(-1);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *
|
||||
mem_strdup(const char *s)
|
||||
{
|
||||
void *str;
|
||||
|
||||
str = strdup(s);
|
||||
if (str) return str;
|
||||
fprintf(stderr, "%s: Error. %s:%i memory allocation of %i bytes failed. %s. string being duplicated: \"%s\"\n",
|
||||
progname, file_in, line, strlen(s) + 1, strerror(errno), s);
|
||||
exit(-1);
|
||||
return NULL;
|
||||
}
|
|
@ -63,6 +63,7 @@ data_write(void)
|
|||
Evas_List *l;
|
||||
|
||||
im = NULL;
|
||||
imlib_set_cache_size(0);
|
||||
for (l = img_dirs; l; l = l->next)
|
||||
{
|
||||
char buf[4096];
|
||||
|
|
|
@ -177,13 +177,7 @@ next_token(char *p, char *end, char **new_p, int *delim)
|
|||
done:
|
||||
*new_p = p;
|
||||
|
||||
tok = malloc(tok_end - tok_start + 2);
|
||||
if (!tok)
|
||||
{
|
||||
fprintf(stderr, "%s: Error. memory allocation of %i bytes failed. %s\n",
|
||||
progname, tok_end - tok_start + 2, strerror(errno));
|
||||
exit(-1);
|
||||
}
|
||||
tok = mem_alloc(tok_end - tok_start + 2);
|
||||
strncpy(tok, tok_start, tok_end - tok_start + 1);
|
||||
tok[tok_end - tok_start + 1] = 0;
|
||||
|
||||
|
@ -215,13 +209,7 @@ stack_id(void)
|
|||
len = 0;
|
||||
for (l = stack; l; l = l->next)
|
||||
len += strlen(l->data) + 1;
|
||||
id = malloc(len);
|
||||
if (!id)
|
||||
{
|
||||
fprintf(stderr, "%s: Error. memory allocation of %i bytes failed. %s\n",
|
||||
progname, len, strerror(errno));
|
||||
exit(-1);
|
||||
}
|
||||
id = mem_alloc(len);
|
||||
id[0] = 0;
|
||||
for (l = stack; l; l = l->next)
|
||||
{
|
||||
|
@ -362,13 +350,7 @@ parse_str(int n)
|
|||
progname, file_in, line, n + 1);
|
||||
exit(-1);
|
||||
}
|
||||
s = strdup(str);
|
||||
if (!s)
|
||||
{
|
||||
fprintf(stderr, "%s: Error. memory allocation of %i bytes failed. %s\n",
|
||||
progname, strlen(str) + 1, strerror(errno));
|
||||
exit(-1);
|
||||
}
|
||||
s = mem_strdup(str);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue