struct sn_interpreter* sn = malloc(sizeof(struct sn_interpreter));
sn->variables = malloc(sizeof(struct sn_interpreter_kv*));
sn->variables[0] = NULL;
+ sn->generics = malloc(sizeof(struct sn_generic**));
+ sn->generics[0] = NULL;
sn_set_handler(sn, "+", math_handler);
sn_set_handler(sn, "-", math_handler);
free(sn->variables[i]);
}
free(sn->variables);
+ for(i = 0; sn->generics[i] != NULL; i++){
+ int j;
+ for(j = 0; sn->generics[i][j] != NULL; j++) sn_generic_free(sn->generics[i][j]);
+ free(sn->generics[i]);
+ }
+ free(sn->generics);
free(sn);
}
}
}
}
- for(i = 0; gens[i] != NULL; i++) sn_generic_free(gens[i]);
- free(gens);
+ int j;
+ struct sn_generic*** oldgens = sn->generics;
+ for(j = 0; oldgens[j] != NULL; j++);
+ sn->generics = malloc(sizeof(struct sn_generic**) * (j + 2));
+ for(j = 0; oldgens[j] != NULL; j++){
+ sn->generics[j] = oldgens[j];
+ }
+ sn->generics[j] = gens;
+ sn->generics[j + 1] = NULL;
+ free(oldgens);
}
return r;
}