Exemple #1
0
void 
free_object(struct object *ob, char *from)
{
    if (d_flag & DEBUG_OB_REF)
	(void)printf("Subtr ref to ob %s: %d (%s)\n", ob->name,
		      ob->ref, from);
    if (!ob->ref || --ob->ref > 0)
	return;
    if (!(ob->flags & O_DESTRUCTED))
    {
	/* This is fatal, and should never happen. */
	fatal("FATAL: Object %p %s ref count 0, but not destructed (from %s).\n",
	    ob, ob->name, from);
    }
    if (ob->interactive)
	fatal("Tried to free an interactive object.\n");
    /*
     * If the program is freed, then we can also free the variable
     * declarations.
     */
    if (ob->name) {
	if (lookup_object_hash(ob->name) == ob)
	    fatal("Freeing object %s but name still in name table\n", ob->name);
	free(ob->name);
	ob->name = 0;
    }
    tot_alloc_object--;
    tot_alloc_dest_object--;
    tot_removed_object++;
    free((char *)ob);
    tot_alloc_object_size -= sizeof (struct object);
}
Exemple #2
0
/* 初始化mudlib中的master */
void init_master() {
    char buf[512];
#ifdef LPC_TO_C
    lpc_object_t *compiled_version;
#endif
    object_t *new_ob;

    if (!strip_name(MASTER_FILE, buf, sizeof buf))
        error("Illegal master file name '%s'\n", MASTER_FILE);

#ifdef LPC_TO_C
    compiled_version = (lpc_object_t *)lookup_object_hash(buf);	/* cv是个lpc的obj */
#endif

    new_ob = load_object(buf, compiled_version);				/* 将master load进来 */
    if (new_ob == 0) {
        fprintf(stderr, "The master file %s was not loaded.\n",
                MASTER_FILE);
        exit(-1);
    }
    set_master(new_ob);		/* 设置master对象 */
}