I am also assuming this has an error, as if I try to call this it is what creates the seg fault.. can you please tell me why?
Code:
rule_t* RuleConstruct(rule_t* rule, rule_t* newrule)
{
char** dep = (char**) malloc(sizeof(char*) * rule->depSize);
int h;
for (h = 0; h < rule->depSize; h++){
dep[h] = malloc((strlen(rule->dependency[h]) + 1) * sizeof(char));
strcpy(dep[h], rule->dependency[h]);
}
char** bld = (char**) malloc(sizeof(char*) * rule->bldSize);
int i;
for (i = 0; i < rule->bldSize; i++){
dep[i] = malloc((strlen(rule->buildcmd[i]) + 1) * sizeof(char));
strcpy(dep[i], rule->buildcmd[i]);
}
char* target = (char*) malloc((strlen(rule->target) + 1) * sizeof(char));
strcpy(target, rule->target);
newrule->dependency = dep;
newrule->buildcmd = bld;
newrule->bldSize = rule->bldSize;
newrule->depSize = rule->depSize;
newrule->target = target;
return newrule;
}