Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- typedef struct _config_main_section ConfigMainSection;
- struct _config_main_section {
- const char *name;
- char **list;
- size_t size;
- };
- static char *config_files[] = { CONFIG_FILES_LOG, CONFIG_FILES_ERR, CONFIG_FILES_PID };
- static char *config_general[] = { CONFIG_GENERAL_NAME, CONFIG_GENERAL_DESCRIPTION };
- static ConfigMainSection sections[] = {
- { CONFIG_FILES, config_files, ARRAY_SIZE(config_services_files) },
- { CONFIG_GENERAL, config_general, ARRAY_SIZE(config_services_general) },
- };
- int func(void) {
- // array_size returns correct value (2), currentSection->name is a proper char*
- ConfigMainSection *main_section = find_config_main_section(sections, ARRAY_SIZE(sections),currentSection->name);
- }
- ConfigMainSection *find_config_main_section(ConfigMainSection *sections[], size_t size, const char *name) {
- ConfigMainSection *ptr = sections;
- ConfigMainSection *endPtr = sections + size;
- while (ptr < endPtr) {
- if(stricmp(ptr->name,name) == 0) {
- // I would expect that at some point, a matching name is found and a pointer to ConfigMainSection is returned
- // yet this point is never reached (segfault)
- return ptr;
- }
- ptr++;
- }
- return NULL;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement