X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Futils_ignorelist.c;h=532eb4b0029837318cf60a2adbecf901a2590b3a;hb=44d73d6556833bcfbc4678a01731aafee95c3caf;hp=1adfbc6b06899c2c58fcc66622fa643a1fe97f7f;hpb=403e429f70e11ac11b6d5af174322b01e45b810a;p=collectd.git diff --git a/src/utils_ignorelist.c b/src/utils_ignorelist.c index 1adfbc6b..532eb4b0 100644 --- a/src/utils_ignorelist.c +++ b/src/utils_ignorelist.c @@ -1,5 +1,5 @@ /** - * collectd - src/config_list.c + * collectd - src/utils_ignorelist.c * Copyright (C) 2006 Lubos Stanek * * This program is free software; you can redistribute it and/ @@ -67,7 +67,6 @@ typedef struct ignorelist_item_s ignorelist_item_t; struct ignorelist_s { int ignore; /* ignore entries */ - int num; /* number of entries */ ignorelist_item_t *head; /* pointer to the first entry */ }; @@ -81,8 +80,6 @@ static inline void ignorelist_append (ignorelist_t *il, ignorelist_item_t *item) item->next = il->head; il->head = item; - - il->num++; } #if HAVE_REGEX_H @@ -246,9 +243,7 @@ void ignorelist_free (ignorelist_t *il) for (this = il->head; this != NULL; this = next) { - DBG ("free - item = 0x%p, numlist %i", (void *) this, il->num); next = this->next; - il->num--; #if HAVE_REGEX_H if (this->rmatch != NULL) { @@ -263,11 +258,7 @@ void ignorelist_free (ignorelist_t *il) } sfree (this); } -#if COLLECTD_DEBUG - if (il->num != 0) - DBG ("after free numlist: %i", il->num); -#endif - il->num = 0; + sfree (il); il = NULL; } /* void ignorelist_destroy (ignorelist_t *il) */ @@ -286,21 +277,6 @@ void ignorelist_set_invert (ignorelist_t *il, int invert) il->ignore = invert ? 0 : 1; } /* void ignorelist_set_invert (ignorelist_t *il, int ignore) */ -/* - * get number of entries in the ignorelist_t - * return int number - */ -int ignorelist_num (ignorelist_t *il) -{ - if (il == NULL) - { - DBG("get num called with ignorelist_t == NULL"); - return (0); - } - - return (il->num); -} /* int ignorelist_num (ignorelist_t *il) */ - /* * append entry into ignorelist_t * return 1 for success @@ -309,7 +285,6 @@ int ignorelist_add (ignorelist_t *il, const char *entry) { int ret; size_t entry_len; - char *entry_copy; if (il == NULL) { @@ -330,6 +305,8 @@ int ignorelist_add (ignorelist_t *il, const char *entry) /* regex string is enclosed in "/.../" */ if ((entry_len > 2) && (entry[0] == '/') && entry[entry_len - 1] == '/') { + char *entry_copy; + /* We need to copy `entry' since it's const */ entry_copy = smalloc (entry_len); memset (entry_copy, '\0', entry_len); @@ -357,8 +334,13 @@ int ignorelist_match (ignorelist_t *il, const char *entry) { ignorelist_item_t *traverse; + assert (il != NULL); + /* if no entries, collect all */ - if (ignorelist_num(il) == 0) + if (il->head == NULL) + return (0); + + if ((entry == NULL) || (strlen (entry) == 0)) return (0); /* traverse list and check entries */