Hi,
I have a serious problem with my allocation of memory, and quite frankly I have no clue why the following code won't work.
Code:
...
if ((dMob = malloc(sizeof(*dMob))) == NULL)
{
log(LOG_E, "load_profile: Cannot allocate memory.");
abort();
}
if ((dMob->pcdata = malloc(sizeof(*dMob->pcdata))) == NULL)
{
log(LOG_E, "load_profile: Cannot allocate memory.");
abort();
}
dMob->pcdata->password="Test."; /* char *password; */
...
It crashes, and throws a segmentation fault after getting to that last statement there. So whats wrong with this thing? Its not having problems allocating the memory. If I remove the last line, the program continues on fine. Buts its like pcdata wasn't allocated, even though I just allocated it.
Any help is greatly appreciated. Thank you very much.
-Jase