From: Wolfgang (Blub) Bumiller Date: Fri, 24 Aug 2012 16:14:39 +0000 (+0200) Subject: ir_value now checks if a name was specified X-Git-Tag: 0.1-rc1~46 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=04dca17cffcf250a6f561b8624fe053b96e37f86;p=xonotic%2Fgmqcc.git ir_value now checks if a name was specified --- diff --git a/ir.c b/ir.c index 0162e8e..1f9a80d 100644 --- 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 e044d75..95fdd57 100644 --- 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);