Last active
January 24, 2019 12:15
-
-
Save pervognsen/bca010dd64623e600b2dfc974968a4a3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef struct { | |
void *data; | |
size_t num_items; | |
size_t max_items; | |
} array_t; | |
// ... | |
typedef struct { | |
union { | |
struct { | |
// Alias the fields of the untyped array with typed pointers and appropriate names. | |
char **files; | |
size_t num_files; | |
}; | |
array_t files_array; | |
}; | |
} file_list_t; | |
void file_list_init(file_list_t *file_list) { | |
array_init(&file_list->files_array, sizeof(char *)); | |
} | |
void file_list_add(file_list_t *file_list, char *filename) { | |
array_add(&file_list->files_array, &filename, sizeof(char *)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment