From: Rick Bird Date: Wed, 11 May 2011 15:02:55 +0000 (-0400) Subject: fixed some typos in modules.c, added memory panic checks, and removed case insentivit... X-Git-Url: https://git.theari.com/?a=commitdiff_plain;h=f0f9b64dd84a9dae5e15f21c62145029628a8025;p=cobramush.git fixed some typos in modules.c, added memory panic checks, and removed case insentivity checking with CHook_Create & Insert since they're called internally. --- diff --git a/src/modules.c b/src/modules.c index eaf7ed2..ca727a7 100644 --- a/src/modules.c +++ b/src/modules.c @@ -76,9 +76,9 @@ CHooks_Init() if (chook_tab[i].mush_key != NULL) sz++; hashinit(&chook_mevents, sz); - for (sz = i = 0; chook_tab[i].key != NULL; i++) + for (i = 0; chook_tab[i].key != NULL; i++) if (chook_tab[i].mush_key != NULL) - hashadd(strupper(chook_tab[i].mush_key), (void *) chook_tab[i].key, &chook_mevents); + hashadd(chook_tab[i].mush_key, (void *) chook_tab[i].key, &chook_mevents); } struct core_hook_t * @@ -87,7 +87,7 @@ CHook_Create(const char *key, int flags) struct core_hook_t *chook; /* check to see if we need to create it */ - if ((chook = (struct core_hook_t *) hashfind(strupper(key), &chook_htab))) { + if ((chook = (struct core_hook_t *) hashfind(key, &chook_htab))) { /* It already exists.. just return this one */ return chook; } @@ -103,7 +103,7 @@ CHook_Create(const char *key, int flags) chook->flags = flags; chook->hooks = NULL; /* Initialized as having no children */ /* Add to the hashtab */ - hashadd(strupper(key), chook, &chook_htab); + hashadd(key, chook, &chook_htab); return chook; } @@ -115,7 +115,7 @@ CHook_Insert(const char *key, char priority, int flags, void *data) struct core_entry_t *new_child, *cur_child; /* Ok first look for the htab entry */ - parent = hashfind(strupper(key), &chook_htab); + parent = hashfind(key, &chook_htab); if (!parent) /* It doesn't exist, return NULL */ return NULL; @@ -170,6 +170,8 @@ CHook_Insert_SC(char *key, dbref object, char *attribute) softcode_block = (struct softcode_hook *) mush_malloc(sizeof(struct softcode_hook), "CHOOK.SOFTCODE_BLOCK"); + if(!softcode_block) + mush_panic("Out of memory"); softcode_block->obj = object; memset(softcode_block->attribute, '\0', ATTRIBUTE_NAME_LIMIT); strncpy(softcode_block->attribute, strupper(attribute), @@ -318,6 +320,7 @@ CHook_SC(struct core_entry_t *entry, const char *format, va_list arguments) int break_count, spot = 0; sc_hook = (struct softcode_hook *) entry->data; + strcpy(global_eval_context.ccom, ""); /* Before we bother with va_list .. Make sure A) Its a good object, B) Its a good attribute */ if (!GoodObject(sc_hook->obj)) @@ -392,15 +395,15 @@ CHook_SC(struct core_entry_t *entry, const char *format, va_list arguments) break_count = 100; start_cpu_timer(); while (!cpu_time_limit_hit && *s) { - r = cmd_buf; + r = global_eval_context.ccom; local_ooref = ooref; ooref = atr->creator; - process_expression(cmd_buf, &r, &s, + process_expression(global_eval_context.ccom, &r, &s, executor, enactor, cause, PE_NOTHING, PT_SEMI, NULL); *r = '\0'; if (*s == ';') s++; - strcpy(tbuf, cmd_buf); + strcpy(tbuf, global_eval_context.ccom); process_command(executor, tbuf, enactor, cause, 0); if (global_eval_context.break_called) { global_eval_context.break_called = 0;