Skip to content

Instantly share code, notes, and snippets.

@Y0lan
Created November 17, 2019 01:29
Show Gist options
  • Save Y0lan/18f7b838cb695812b193eb04163df29a to your computer and use it in GitHub Desktop.
Save Y0lan/18f7b838cb695812b193eb04163df29a to your computer and use it in GitHub Desktop.
typedef struct struct_action {
char * name;
char * url;
unsigned int max_depth;
unsigned short versioning;
char ** type;
unsigned int numberOfTypes;
} struct_action;
typedef struct struct_actions {
struct_action * action;
int numberOfActions;
} struct_actions;
struct_action * fillActionWithValue(char * key, char * value)
{
struct_action * action = malloc(sizeof(struct_action));
if(action == NULL) return action;
if(strcmp(key,"max-depth") == 0) action->max_depth = isNumber(value);
return action;
}
function2(...){
...
if(action) action[nbActions - 1] = fillActionWithValue(key,value)[0];
...
}
function1(struct_actions actions, ...){
while (something)) {
int currentNbAction = nbActions;
function2(..., actions->action, nbActions);
nbActions = update();
if(nbActions || changed(nbAction)) {
actions->action = realloc(actions->action, sizeof(struct_action *) * nbActions);
}
countLine = countLine + 1;
}
actions->numberOfActions = nbActions;
}
int main(void){
struct_actions actions;
struct_actions *p_actions = &actions;
function1(p_actions);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment