Browse Source

Minor fixes.

Marco Bambini 7 years ago
parent
commit
c1bc295952
2 changed files with 3 additions and 1 deletions
  1. 1 1
      src/compiler/gravity_ast.h
  2. 2 0
      src/compiler/gravity_ircode.c

+ 1 - 1
src/compiler/gravity_ast.h

@@ -48,7 +48,7 @@ typedef struct {
 	uint32_t	refcount;					// reference count to manage duplicated nodes
 	uint32_t	refcount;					// reference count to manage duplicated nodes
 	gtoken_s	token;						// token type and location
 	gtoken_s	token;						// token type and location
 	bool		is_assignment;				// flag to check if it is an assignment node
 	bool		is_assignment;				// flag to check if it is an assignment node
-    void        *meta;                      // meta decoration (used only in decl nodes in this versin but added here in order to prepare for a more complete solution)
+    void        *meta;                      // meta decoration (used only in decl nodes in this version but added here in order to prepare for a more complete solution)
     void        *decl;                      // enclosing declaration node
     void        *decl;                      // enclosing declaration node
 } gnode_t;
 } gnode_t;
 
 

+ 2 - 0
src/compiler/gravity_ircode.c

@@ -34,6 +34,7 @@ struct ircode_t {
 
 
 ircode_t *ircode_create (uint16_t nlocals) {
 ircode_t *ircode_create (uint16_t nlocals) {
 	ircode_t *code = (ircode_t *)mem_alloc(NULL, sizeof(ircode_t));
 	ircode_t *code = (ircode_t *)mem_alloc(NULL, sizeof(ircode_t));
+    if (!code) return NULL;
 	code->label_counter = 0;
 	code->label_counter = 0;
 	code->nlocals = nlocals;
 	code->nlocals = nlocals;
 	code->ntemps = 0;
 	code->ntemps = 0;
@@ -41,6 +42,7 @@ ircode_t *ircode_create (uint16_t nlocals) {
 	code->error = false;
 	code->error = false;
 
 
 	code->list = mem_alloc(NULL, sizeof(code_r));
 	code->list = mem_alloc(NULL, sizeof(code_r));
+    if (!code->list) return NULL;
 	marray_init(*code->list);
 	marray_init(*code->list);
 	marray_init(code->label_true);
 	marray_init(code->label_true);
 	marray_init(code->label_false);
 	marray_init(code->label_false);