X-Git-Url: https://arthur.barton.de/gitweb/?a=blobdiff_plain;f=src%2Fadaptive_resortable_list.h;h=609cd0c43a2c2e55342dbd56f6c3671d685beaa8;hb=32e8eda4c4d6370e96233a69cab861b2ebb5cc9a;hp=b338afdaa7c100ecba4660715c0d688ed2418530;hpb=27a1dbbe6ee89eb04cc6f6865974b71ba57a120d;p=netdata.git diff --git a/src/adaptive_resortable_list.h b/src/adaptive_resortable_list.h index b338afda..609cd0c4 100644 --- a/src/adaptive_resortable_list.h +++ b/src/adaptive_resortable_list.h @@ -56,6 +56,8 @@ typedef struct arl_entry { } ARL_ENTRY; typedef struct arl_base { + char *name; + size_t iteration; // incremented on each iteration (arl_begin()) size_t found; // the number of expected keywords found in this iteration size_t expected; // the number of expected keywords @@ -93,7 +95,7 @@ typedef struct arl_base { } ARL_BASE; // create a new ARL -extern ARL_BASE *arl_create(void (*processor)(const char *, uint32_t, const char *, void *), size_t rechecks); +extern ARL_BASE *arl_create(const char *name, void (*processor)(const char *, uint32_t, const char *, void *), size_t rechecks); // free an ARL extern void arl_free(ARL_BASE *arl_base); @@ -116,6 +118,11 @@ extern void arl_begin(ARL_BASE *base); static inline int arl_check(ARL_BASE *base, const char *keyword, const char *value) { ARL_ENTRY *e = base->next_keyword; +#ifdef NETDATA_INTERNAL_CHECKS + if(unlikely((base->fast + base->slow) % (base->expected + base->allocated) == 0 && (base->fast + base->slow) > (base->expected + base->allocated) * base->iteration)) + info("ARL '%s': Did you forget to call arl_begin()?", base->name); +#endif + // it should be the first entry (pointed by base->next_keyword) if(likely(!strcmp(keyword, e->name))) { // it is