-int typedef_add(struct lex_file *file, const char *from, const char *to) {
- unsigned int hash = typedef_hash(to);
- typedef_node *find = typedef_table[hash];
-
- if (find)
- return error(file, ERROR_PARSE, "typedef for %s already exists or conflicts\n", to);
-
- /* check if the type exists first */
- if (strncmp(from, "float", sizeof("float")) == 0 ||
- strncmp(from, "vector", sizeof("vector")) == 0 ||
- strncmp(from, "string", sizeof("string")) == 0 ||
- strncmp(from, "entity", sizeof("entity")) == 0 ||
- strncmp(from, "void", sizeof("void")) == 0) {
-
- typedef_table[hash] = mem_a(sizeof(typedef_node));
- typedef_table[hash]->name = util_strdup(from);
- return -100;
- } else {
- /* search the typedefs for it (typedef-a-typedef?) */
- typedef_node *find = typedef_table[typedef_hash(from)];
- if (find) {
- typedef_table[hash] = mem_a(sizeof(typedef_node));
- typedef_table[hash]->name = util_strdup(find->name);
- return -100;
- }
- }
- return error(file, ERROR_PARSE, "cannot typedef `%s` (not a type)\n", from);
+int typedef_add(lex_file *file, const char *from, const char *to) {
+ unsigned int hash = typedef_hash(to);
+ typedef_node *find = typedef_table[hash];
+
+ if (find)
+ return error(file, ERROR_PARSE, "typedef for %s already exists or conflicts\n", to);
+
+ /* check if the type exists first */
+ if (strncmp(from, "float", sizeof("float")) == 0 ||
+ strncmp(from, "vector", sizeof("vector")) == 0 ||
+ strncmp(from, "string", sizeof("string")) == 0 ||
+ strncmp(from, "entity", sizeof("entity")) == 0 ||
+ strncmp(from, "void", sizeof("void")) == 0) {
+
+ typedef_table[hash] = mem_a(sizeof(typedef_node));
+ if (typedef_table[hash])
+ typedef_table[hash]->name = util_strdup(from);
+ else
+ return error(file, ERROR_PARSE, "ran out of resources for typedef %s\n", to);
+ return -100;
+ } else {
+ /* search the typedefs for it (typedef-a-typedef?) */
+ find = typedef_table[typedef_hash(from)];
+ if (find) {
+ typedef_table[hash] = mem_a(sizeof(typedef_node));
+ if (typedef_table[hash])
+ typedef_table[hash]->name = util_strdup(find->name);
+ else
+ return error(file, ERROR_PARSE, "ran out of resources for typedef %s\n", to);
+ return -100;
+ }
+ }
+ return error(file, ERROR_PARSE, "cannot typedef `%s` (not a type)\n", from);