mirror of https://github.com/xzeldon/htop.git
Improve the DynamicMeter_search API to make 'key' optional
Thanks to @BenBE for the suggestion.
This commit is contained in:
parent
9cbee01877
commit
0daefbe4b4
|
@ -52,7 +52,8 @@ bool DynamicMeter_search(Hashtable* dynamics, const char* name, unsigned int* ke
|
|||
DynamicIterator iter = { .key = 0, .name = name, .found = false };
|
||||
if (dynamics)
|
||||
Hashtable_foreach(dynamics, DynamicMeter_compare, &iter);
|
||||
*key = iter.key;
|
||||
if (key)
|
||||
*key = iter.key;
|
||||
return iter.found;
|
||||
}
|
||||
|
||||
|
|
|
@ -140,8 +140,7 @@ static bool PCPDynamicMeter_validateMeterName(char* key, const char* path, unsig
|
|||
|
||||
// Ensure a meter name has not been defined previously
|
||||
static bool PCPDynamicMeter_uniqueName(char* key, const char* path, unsigned int line, PCPDynamicMeters* meters) {
|
||||
unsigned int param = 0;
|
||||
if (DynamicMeter_search(meters->table, key, ¶m) == false)
|
||||
if (DynamicMeter_search(meters->table, key, NULL) == false)
|
||||
return true;
|
||||
|
||||
fprintf(stderr, "%s: duplicate name at %s line %u: \"%s\", ignored\n",
|
||||
|
@ -199,6 +198,7 @@ static void PCPDynamicMeter_parseFile(PCPDynamicMeters* meters, const char* path
|
|||
if (caption) {
|
||||
free_and_xStrdup(&meter->super.caption, caption);
|
||||
free(caption);
|
||||
caption = NULL;
|
||||
}
|
||||
} else if (value && meter && String_eq(key, "description")) {
|
||||
free_and_xStrdup(&meter->super.description, value);
|
||||
|
|
Loading…
Reference in New Issue