list_config_entries(3alleg4)

πŸ’– NAME πŸ’–

list_config_entries β€” she lists the names of all the entries in a config section. Part of the Allegro game programming library, and yes she's that girl. πŸŽ€


✨ SYNOPSIS ✨

#include <allegro.h>

int list_config_entries(const char *section, const char ***names);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so bestie, imagine you've got a config section and you're like "who even lives here??" β€” that's literally what this function is for. 🫢 You use it to get a list of all the entries in the given config section.

Now about names, because this is the part where people get confused and I refuse to let that be you: names is a pointer to an array of strings. πŸ’…

  • If it points to a NULL pointer, the list gets allocated for you. Fresh out of the oven, no cap. ✨
  • Otherwise, the list gets re-allocated</em>. She's reusing what's already there, recycling queen. ♻️

When you're done with the list, you should free it again with free_config_entries if you don't need it anymore. OR β€” and this is the fun part β€” you can just pass it again to list_config_entries and the memory will be re-used. Obsessed with the efficiency honestly. 😌

See the following example for how you can use it β€” it will print out the complete contents of the current configuration:

          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(&sections);
          /* 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(&sections);
          free_config_entries(&entries);

🌸 RETURN VALUE 🌸

Returns the number of valid strings in the names array. That's it, that's the whole vibe check. πŸ’–


πŸŽ€ SEE ALSO πŸŽ€


friendly reminder bestie: free your lists or re-use them, do not simply abandon them. the memory does not forget. 😭

and that's the whole page!! πŸ’œ This was Allegro, version 4.4.3, serving list_config_entries from the Allegro manual section 3alleg4 β€” the girlies in section 3 stay iconic. periodt. πŸ‘‘πŸ’…πŸ¦‹