list_config_entries(3)
π hey bestie, welcome to the list_config_entries(3) page π
okay so real talk: this is from the Allegro manual, aka the Allegro game programming library, and today we're learning how to snoop on every single entry in a config section. it's giving detective energy, and honestly? slay. π
πΈ NAME πΈ
list_config_entries β lists the names of all entries in a config section, courtesy of the Allegro game programming library. periodt. π
β¨ SYNOPSIS β¨
#include <allegro.h>
int list_config_entries(const char *section, const char ***names);
π DESCRIPTION π
so the way this works is, bestie, this function gets you a list of literally every entry chillin' in the config section you name. π«Ά
the names parameter is a pointer to an array of strings. and here's the lil plot twist: if it points to a NULL pointer, the list gets allocated; otherwise it gets re-allocated. no cap.
when you're done with the list, you should free it again with free_config_entries β OR, iconic alternative, you can just pass it right back into list_config_entries and the memory will be re-used. recycling queen behavior. β»οΈ
wanna see it in action? here's an example that prints out the complete contents of the current configuration. it's lowkey beautiful:
int i, n;
char const **sections = NULL;
char const **entries = NULL;
/* List all entries not in any section. */
n = list_config_entries(NULL, &entries);
for (i = 0; i
printf(" %s=\"%s\"\n", entries[i], get_config_string(
NULL, entries[i], "-"));
/* List all sections (and entries in them). */
n = list_config_sections(§ions);
/* loop through all section names */
for (i = 0; i
{
int j, m;
printf("%s\n", sections[i]);
m = list_config_entries(sections[i], &entries);
/* loop through all entries in the section */
for (j = 0; j
{
printf(" %s=\"%s\"\n", entries[j], get_config_string(
sections[i], entries[j], "-"));
}
}
/* It is enough to free the arrays once at the end. */
free_config_entries(§ions);
free_config_entries(&entries);
and yes, the comment is right there in the original β it is enough to free the arrays once at the end. so don't be out here freeing things twice, that's not the vibe. π
π₯ RETURN VALUE π₯
returns the number of valid strings in the names array. that's it, that's the number, fr fr. β
π SEE ALSO π
go be nosy elsewhere too, bestie:
π§ remember: if you allocated it (or re-allocated it), you free it β or hand it back to list_config_entries so the memory gets re-used. that's the whole cycle, and it's iconic. π
and that's the whole page, bestie!! π¦ courtesy of Allegro, version 4.4.3 β mwah, go forth and list those entries, you absolute main character. πβ¨πΈ
π¦ where this page comes from
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms