From 8af67ddb82250f4b2cc8ada73dbaac3541c53223 Mon Sep 17 00:00:00 2001 From: Stathis Kamperis Date: Mon, 10 Sep 2007 15:03:50 +0300 Subject: [PATCH] Fix state_remove() in regard to key --- misc/fsm/main.c | 4 +++- misc/fsm/states.c | 4 ++-- misc/fsm/states.h | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/misc/fsm/main.c b/misc/fsm/main.c index eda0d42..b669459 100644 --- a/misc/fsm/main.c +++ b/misc/fsm/main.c @@ -16,7 +16,7 @@ int main(void) state_t mystate, mystate2; unsigned int x = 1, y = 2, z = 3, a = 4, b = 5; - state_init(&mystate, 2, 10); + state_init(&mystate, 2, 1); state_add_evt(&mystate, x, "event1", foo1, &mystate2); state_add_evt(&mystate, y, "event2", foo2, &mystate2); @@ -27,6 +27,8 @@ int main(void) state_print_evts(&mystate); + state_rem_evt(&mystate, b); + printf("________________________\n"); state_print_evts(&mystate); diff --git a/misc/fsm/states.c b/misc/fsm/states.c index 03f07c7..6a94f6b 100644 --- a/misc/fsm/states.c +++ b/misc/fsm/states.c @@ -43,9 +43,9 @@ stret_t state_add_evt(state_t *state, unsigned int key, char *desc, void (*actio return ST_OK; } -stret_t state_rem_evt(state_t *state, unsigned int *key) +stret_t state_rem_evt(state_t *state, unsigned int key) { - if (htable_remove(&state->evttable, key) == HT_NOTFOUND) + if (htable_remove(&state->evttable, &key) == HT_NOTFOUND) return ST_NOTFOUND; return ST_OK; diff --git a/misc/fsm/states.h b/misc/fsm/states.h index d394f33..de13239 100644 --- a/misc/fsm/states.h +++ b/misc/fsm/states.h @@ -6,7 +6,7 @@ /* Function prototypes */ stret_t state_init(state_t *state, size_t size, unsigned int factor); stret_t state_add_evt(state_t *state, unsigned int key, char *desc, void (*actionf)(void *data), state_t *newstate); -stret_t state_rem_evt(state_t *state, unsigned int *key); +stret_t state_rem_evt(state_t *state, unsigned int key); stret_t state_free(state_t *state); void state_print_evts(const state_t *state); -- 2.11.4.GIT