From 569c77ab809a04013fe6fc76764f5e496e598401 Mon Sep 17 00:00:00 2001 From: Allanis Date: Mon, 26 Aug 2013 15:37:21 +0100 Subject: [PATCH] [Fix] Bug where hooks would not get removed properly. --- src/hook.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/hook.c b/src/hook.c index aeec1ee..bd9fe5a 100644 --- a/src/hook.c +++ b/src/hook.c @@ -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);