From 5bc599c5298dbdf1c05acf324df5b468b375958e Mon Sep 17 00:00:00 2001 From: Thomas Harning Jr Date: Fri, 15 Feb 2008 23:50:32 -0500 Subject: [PATCH] core/filters: renamed internal items for FilterChain --- core/include/filters/FilterChain.h | 6 +++--- core/src/filters/FilterChain.c | 34 +++++++++++++++++----------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/core/include/filters/FilterChain.h b/core/include/filters/FilterChain.h index 6224082..bafcf23 100644 --- a/core/include/filters/FilterChain.h +++ b/core/include/filters/FilterChain.h @@ -4,14 +4,14 @@ #include "config.h" #include "filter.h" -typedef void (*filter_state_release)(void *); +typedef void (*Filter_stateRelease)(void *); void FilterChain_action(void *state, FilterMode mode, data_item_t *item, FilterAction_next next, void *nextData); void *new_FilterChain(); void free_FilterChain(void *state); -void FilterChain_append(void *state, FilterAction action, void *actionState, filter_state_release release); -void FilterChain_prepend(void *state, FilterAction action, void *actionState, filter_state_release release); +void FilterChain_append(void *state, FilterAction action, void *actionState, Filter_stateRelease release); +void FilterChain_prepend(void *state, FilterAction action, void *actionState, Filter_stateRelease release); /* NOTE: Removal actions and deletion of filter state may need some workflow design * since if any item is removed while its being used, problems will ensue */ diff --git a/core/src/filters/FilterChain.c b/core/src/filters/FilterChain.c index 9cae834..a564610 100644 --- a/core/src/filters/FilterChain.c +++ b/core/src/filters/FilterChain.c @@ -3,19 +3,19 @@ #include /* assert */ #include /* memmove */ -typedef struct filter_pair { +typedef struct FilterPair { FilterAction action; void *actionState; - filter_state_release stateRelease; -} filter_pair_t; + Filter_stateRelease stateRelease; +} FilterPair; typedef struct FilterChain { - filter_pair_t *actions; + FilterPair *actions; size_t numActions; -} FilterChain_t; +} FilterChain; typedef struct FilterChain_state { - FilterChain_t *chain; + FilterChain *chain; size_t index; FilterAction_next next; void *nextData; @@ -51,7 +51,7 @@ static void FilterChain_next(void *nextData, FilterMode mode, data_item_t *item) } void FilterChain_action(void *filter, FilterMode mode, data_item_t *item, FilterAction_next next, void *nextData) { - FilterChain_t *chain = (FilterChain_t*)filter; + FilterChain *chain = (FilterChain*)filter; FilterChain_State *state; assert(filter && next); state = calloc(1, sizeof(FilterChain_State)); @@ -79,7 +79,7 @@ fail: } void *new_FilterChain() { - FilterChain_t *chain = (FilterChain_t*)calloc(1, sizeof(FilterChain_t)); + FilterChain *chain = (FilterChain*)calloc(1, sizeof(FilterChain)); if(!chain) goto fail; return chain; fail: @@ -87,7 +87,7 @@ fail: return NULL; } void free_FilterChain(void *state) { - FilterChain_t *chain = (FilterChain_t*)state; + FilterChain *chain = (FilterChain*)state; int idx; /* Free all chain items */ for(idx = 0; idx < chain->numActions; idx++) { @@ -102,32 +102,32 @@ void free_FilterChain(void *state) { } /* Naive in that it doesn't even try to act like a 'vector' */ -static void resize_chain(FilterChain_t *chain, int newSize) { +static void resize_chain(FilterChain *chain, int newSize) { /* XXX: If out of memory, this will abort */ - filter_pair_t *newActions = realloc(chain->actions, newSize * sizeof(filter_pair_t)); + FilterPair *newActions = realloc(chain->actions, newSize * sizeof(FilterPair)); assert(newSize == 0 || newActions); chain->actions = newActions; chain->numActions = newSize; } -static void set_chain_action(FilterChain_t *chain, int index, FilterAction action, void *actionState, filter_state_release release) { +static void set_chain_action(FilterChain *chain, int index, FilterAction action, void *actionState, Filter_stateRelease release) { chain->actions[index].action = action; chain->actions[index].actionState = actionState; chain->actions[index].stateRelease = release; } -void FilterChain_append(void *state, FilterAction action, void *actionState, filter_state_release release) { - FilterChain_t *chain = (FilterChain_t*)state; +void FilterChain_append(void *state, FilterAction action, void *actionState, Filter_stateRelease release) { + FilterChain *chain = (FilterChain*)state; int newPos = chain->numActions; resize_chain(chain, newPos + 1); set_chain_action(chain, newPos, action, actionState, release); } -void FilterChain_prepend(void *state, FilterAction action, void *actionState, filter_state_release release) { - FilterChain_t *chain = (FilterChain_t*)state; +void FilterChain_prepend(void *state, FilterAction action, void *actionState, Filter_stateRelease release) { + FilterChain *chain = (FilterChain*)state; int oldLen = chain->numActions; resize_chain(chain, chain->numActions + 1); - memmove(chain->actions + sizeof(filter_pair_t), chain->actions, oldLen * sizeof(filter_pair_t)); + memmove(chain->actions + sizeof(FilterPair), chain->actions, oldLen * sizeof(FilterPair)); set_chain_action(chain, 0, action, actionState, release); } -- 2.11.4.GIT