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,6 +52,7 @@ bool DynamicMeter_search(Hashtable* dynamics, const char* name, unsigned int* ke
|
||||||
DynamicIterator iter = { .key = 0, .name = name, .found = false };
|
DynamicIterator iter = { .key = 0, .name = name, .found = false };
|
||||||
if (dynamics)
|
if (dynamics)
|
||||||
Hashtable_foreach(dynamics, DynamicMeter_compare, &iter);
|
Hashtable_foreach(dynamics, DynamicMeter_compare, &iter);
|
||||||
|
if (key)
|
||||||
*key = iter.key;
|
*key = iter.key;
|
||||||
return iter.found;
|
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
|
// Ensure a meter name has not been defined previously
|
||||||
static bool PCPDynamicMeter_uniqueName(char* key, const char* path, unsigned int line, PCPDynamicMeters* meters) {
|
static bool PCPDynamicMeter_uniqueName(char* key, const char* path, unsigned int line, PCPDynamicMeters* meters) {
|
||||||
unsigned int param = 0;
|
if (DynamicMeter_search(meters->table, key, NULL) == false)
|
||||||
if (DynamicMeter_search(meters->table, key, ¶m) == false)
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
fprintf(stderr, "%s: duplicate name at %s line %u: \"%s\", ignored\n",
|
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) {
|
if (caption) {
|
||||||
free_and_xStrdup(&meter->super.caption, caption);
|
free_and_xStrdup(&meter->super.caption, caption);
|
||||||
free(caption);
|
free(caption);
|
||||||
|
caption = NULL;
|
||||||
}
|
}
|
||||||
} else if (value && meter && String_eq(key, "description")) {
|
} else if (value && meter && String_eq(key, "description")) {
|
||||||
free_and_xStrdup(&meter->super.description, value);
|
free_and_xStrdup(&meter->super.description, value);
|
||||||
|
|
Loading…
Reference in New Issue