Take a look at this example function:
RuntimeConfiguration* conf_rt_conf() {
RuntimeConfiguration *conf;
conf = new RuntimeConfiguration();
conf->arch_path="./archive";
conf->err_log="./err_log";
conf->fail_log="./fail_log";
conf->msg_log="./msg_log";
conf->save="html, htm, php";
conf->ignore="jpg, gif";
conf->cookies="";
return conf;
}
Everything here works fine, but when I run something like this:
DatabaseInput** conf_db_input() {
DatabaseInput **db_input;
db_input=(DatabaseInput **)malloc(NUMB_SITES*sizeof(DatabaseInput *));
for (int i=0;i<NUMB_SITES;i++) db_input[0]= new DatabaseInput();
db_input[0]->full_name="ABCNews";
db_input[0]->alias="abcn";
db_input[0]->prefix="/eng";
db_input[1]->full_name="Rzeczpospolita";
db_input[1]->alias="rp";
db_input[1]->prefix="/pol";
return db_input;
}
I get segmentation fault on first assignment. It probably has something to do with the fixed memory block allocated for this struct. How do I get it to work properly?