]> git.rm.cloudns.org Git - xonotic/gmqcc.git/commitdiff
ir_value now checks if a name was specified
authorWolfgang (Blub) Bumiller <blub@speed.at>
Fri, 24 Aug 2012 16:14:39 +0000 (18:14 +0200)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Fri, 24 Aug 2012 16:14:39 +0000 (18:14 +0200)
ir.c
ir.h

diff --git a/ir.c b/ir.c
index 0162e8e21845dee8931c7b40def150b628476559..1f9a80db3d213436fce94ad993f45dd46d1ab31b 100644 (file)
--- a/ir.c
+++ b/ir.c
@@ -630,7 +630,11 @@ ir_value* ir_value_var(const char *name, int storetype, int vtype)
     self->context.file = "<@no context>";
     self->context.line = 0;
     self->name = NULL;
-    ir_value_set_name(self, name);
+    if (name && !ir_value_set_name(self, name)) {
+        irerror(self->context, "out of memory");
+        mem_d(self);
+        return NULL;
+    }
 
     memset(&self->constval, 0, sizeof(self->constval));
     memset(&self->code,     0, sizeof(self->code));
@@ -723,11 +727,12 @@ void ir_value_delete(ir_value* self)
     mem_d(self);
 }
 
-void ir_value_set_name(ir_value *self, const char *name)
+bool ir_value_set_name(ir_value *self, const char *name)
 {
     if (self->name)
         mem_d((void*)self->name);
     self->name = util_strdup(name);
+    return !!self->name;
 }
 
 bool ir_value_set_float(ir_value *self, float f)
diff --git a/ir.h b/ir.h
index e044d75163fb318c4f933ecefdeb7b4918b48abf..95fdd57520d50ec724e10cc8969175d5dd454bf7 100644 (file)
--- a/ir.h
+++ b/ir.h
@@ -83,7 +83,7 @@ ir_value* ir_value_var(const char *name, int st, int vtype);
  */
 ir_value* ir_value_out(struct ir_function_s *owner, const char *name, int st, int vtype);
 void      ir_value_delete(ir_value*);
-void      ir_value_set_name(ir_value*, const char *name);
+bool      ir_value_set_name(ir_value*, const char *name);
 ir_value* ir_value_vector_member(ir_value*, unsigned int member);
 
 MEM_VECTOR_PROTO_ALL(ir_value, struct ir_instr_s*, reads);