Objid db_create_object(void) { Object *o; Objid oid; o = dbpriv_new_object(); oid = o->id; o->name = str_dup(""); o->flags = 0; o->parent = o->child = o->sibling = NOTHING; o->location = o->contents = o->next = NOTHING; o->propval = 0; o->propdefs.max_length = 0; o->propdefs.cur_length = 0; o->propdefs.l = 0; o->verbdefs = 0; return oid; }
static int read_object(void) { Objid oid; Object *o; char s[20]; int i; Verbdef *v, **prevv; int nprops; if (dbio_scanf("#%d", &oid) != 1 || oid != db_last_used_objid() + 1) return 0; dbio_read_line(s, sizeof(s)); if (strcmp(s, " recycled\n") == 0) { dbpriv_new_recycled_object(); return 1; } else if (strcmp(s, "\n") != 0) return 0; o = dbpriv_new_object(); o->name = dbio_read_string_intern(); (void) dbio_read_string(); /* discard old handles string */ o->flags = dbio_read_num(); o->owner = dbio_read_objid(); o->location = dbio_read_objid(); o->contents = dbio_read_objid(); o->next = dbio_read_objid(); o->lastcontents = NOTHING; o->parent = dbio_read_objid(); o->child = dbio_read_objid(); o->sibling = dbio_read_objid(); o->lastchild = NOTHING; o->verbdefs = 0; prevv = &(o->verbdefs); for (i = dbio_read_num(); i > 0; i--) { v = mymalloc(sizeof(Verbdef), M_VERBDEF); read_verbdef(v); *prevv = v; prevv = &(v->next); } o->propdefs.cur_length = 0; o->propdefs.max_length = 0; o->propdefs.l = 0; if ((i = dbio_read_num()) != 0) { o->propdefs.l = mymalloc(i * sizeof(Propdef), M_PROPDEF); o->propdefs.cur_length = i; o->propdefs.max_length = i; for (i = 0; i < o->propdefs.cur_length; i++) o->propdefs.l[i] = read_propdef(); } nprops = dbio_read_num(); if (nprops) o->propval = mymalloc(nprops * sizeof(Pval), M_PVAL); else o->propval = 0; for (i = 0; i < nprops; i++) { read_propval(o->propval + i); } return 1; }