[Fix] Bug where hooks would not get removed properly.

This commit is contained in:
Allanis 2013-08-26 15:37:21 +01:00
parent 68a82bd3c9
commit 569c77ab80

View File

@ -6,6 +6,8 @@
#include "xml.h"
#include "hook.h"
#define HOOK_CHUNK 32 /* Size to grow by when out of space. */
/* The hook. */
typedef struct Hook_ {
unsigned int id; /* Unique id. */
@ -65,7 +67,7 @@ unsigned int hook_add(unsigned int parent, char* func, char* stack) {
/* If the memory must grow. */
if(hook_nstack+1 > hook_mstack) {
hook_mstack += 5;
hook_mstack += HOOK_CHUNK;
hook_stack = realloc(hook_stack, hook_mstack*sizeof(Hook));
}
@ -135,7 +137,7 @@ int hooks_run(char* stack) {
hook_runningstack = 0; /* Not running hooks anymore. */
for(i = 0; i < hook_nstack; i++)
if((strcmp(stack, hook_stack[i].stack)==0) && hook_stack[i].delete) {
if(hook_stack[i].delete) { /* Delete any that need deleting. */
hook_rm(hook_stack[i].id);
i--;
}
@ -199,7 +201,7 @@ int hook_save(xmlTextWriterPtr writer) {
xmlw_startElem(writer, "hook");
/*xmlw_attr(writer, "id", "%u", h->id); // I don't think it's needed. */
/*xmlw_attr(writer, "id", "%u", h->id); /* I don't think it's needed. */
xmlw_elem(writer, "parent", "%u", h->parent);
xmlw_elem(writer, "func", "%s", h->func);
xmlw_elem(writer, "stack", "%s", h->stack);