Mercurial > repos > rhope
view blueprint.c @ 121:1af91ceaaf49
Fixed memory leak when an output is only attached to a single null input
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 28 Oct 2010 21:04:12 -0400 |
parents | 76568becd6d6 |
children |
line wrap: on
line source
#include "datum.h" #include "structs.h" #include "parser.h" #include "interp.h" int vis_blueprint_new(datum ** params, queue_entry * entry) { company * comp = create_company(entry->instance->def->program, params[0]->c.generic.data, 0, 0, TRUE); release_ref(params[0]); params[0] = new_datum(BUILTIN_TYPE_BLUEPRINT, 2, 0, entry->instance->def->program); params[0]->c.generic.data = comp; return 0; } int vis_blueprint_addfield(datum ** params, queue_entry * entry) { company * comp = params[0]->c.generic.data; char * type_name = params[2]->c.generic.data; int type; switch(type_name[0]) { case 'B': if(strcmp(type_name, "Byte")) type = ROOM_VIS_REF; else type = ROOM_BYTE; break; case 'W': if(strcmp(type_name, "Word")) type = ROOM_VIS_REF; else type = ROOM_SHORT; break; case 'L': if(strcmp(type_name, "Long")) type = ROOM_VIS_REF; else type = ROOM_LONG; break; case 'D': if(strcmp(type_name, "Double")) type = ROOM_VIS_REF; else type = ROOM_DOUBLE; break; case 'S': if(strcmp(type_name, "Single")) type = ROOM_VIS_REF; else type = ROOM_SINGLE; break; default: type = ROOM_VIS_REF; break; } add_comp_room(comp, params[1]->c.generic.data, -1, -1, type, type); release_ref(params[1]); release_ref(params[2]); return 0; } int vis_blueprint_name(datum ** params, queue_entry * entry) { company * comp = params[0]->c.generic.data; release_ref(params[0]); params[0] = make_string(comp->name, -1, entry->instance->def->program); return 0; } int vis_blueprint_getfields(datum ** params, queue_entry * entry) { int i; company * comp = params[0]->c.generic.data; release_ref(params[0]); params[0] = create_list(entry->instance->def->program); for(i = 0; i < comp->num_rooms; ++i) { params[1] = make_string(comp->room_list[i].name, -1, entry->instance->def->program); vis_list_append(params,entry); } return 0; } int vis_get_blueprint(datum ** params, queue_entry * entry) { company * comp = params[0]->company; release_ref(params[0]); params[0] = new_datum(BUILTIN_TYPE_BLUEPRINT, 2, 0, entry->instance->def->program); params[0]->c.generic.data = comp; return 0; } int vis_get_field(datum ** params, queue_entry * entry) { datum * name = params[1]; int returnval = get_comp_room_by_name(params, name->c.generic.data, NULL, entry, entry->instance->def->program); release_ref(name); return returnval; } int vis_set_field(datum ** params, queue_entry * entry) { datum * name = params[1]; int returnval; params[1] = params[2]; returnval = set_comp_room_by_name(params, name->c.generic.data, NULL, entry, entry->instance->def->program); release_ref(name); return returnval; } int vis_program_newblueprint(datum ** params, queue_entry * entry) { program * prog = params[0]->c.generic.data; company * comp = create_company(prog, params[1]->c.generic.data, 0, 0, TRUE); release_ref(params[1]); params[1] = new_datum(BUILTIN_TYPE_BLUEPRINT, 2, 0, entry->instance->def->program); params[1]->c.generic.data = comp; return 0; }