aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--unit/src/unit.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/unit/src/unit.c b/unit/src/unit.c
index 95de080..12d251e 100644
--- a/unit/src/unit.c
+++ b/unit/src/unit.c
@@ -9,10 +9,11 @@ typedef struct bh_unit_s
} bh_unit_t;
static bh_unit_t *root = NULL;
+static bh_unit_t *last = NULL;
void bh_unit_add(const char *name, bh_unit_cb_t func)
{
- bh_unit_t *unit, *current;
+ bh_unit_t *unit;
unit = malloc(sizeof(*unit));
if (!unit)
@@ -22,14 +23,11 @@ void bh_unit_add(const char *name, bh_unit_cb_t func)
unit->func = func;
unit->next = NULL;
- current = root;
- while (current && current->next)
- current = current->next;
-
- if (current)
- current->next = unit;
+ if (last)
+ last->next = unit;
else
root = unit;
+ last = unit;
}
int bh_unit_run(void)