ir_value now checks if a name was specified

This commit is contained in:
Wolfgang (Blub) Bumiller 2012-08-24 18:14:39 +02:00
parent 8e990b65f3
commit 04dca17cff
2 changed files with 8 additions and 3 deletions

9
ir.c
View file

@ -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)

2
ir.h
View file

@ -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);