I try to dynamacly allocate memory during run time since i don't know how much memory I need when I start the prog since it is up to the user (trying to make a text editor) so I have to dynamacly allocate memory alot, I have made a board search but didn't find anything which made the program work and i googled it. Anyway here is the code which won't work:
Code:
if (cheak>=pline)
/*kolla ifall mer minne behövs*/
{
wprintw(win," %d %d",pline,cheak);
pline++;
wprintw(win," %d",pline);
store=realloc (buff,pline*sizeof(int));
if(store == NULL)
{
endwin ();
printf("Not enuf free memory\n");
exit(0);
}
buff=store;
buff [pline]=calloc((pcol+1),sizeof(int));
if(buff [pline] == NULL)
{
endwin();
printf("not enuf free memory\n");
exit(0);
}
free(store);
store=NULL;
wprintw(win,"allocating ok! %p %p %p",store,buff [pline],buff);
}
buff [cheak] [j-1] = ch;
both buff and point are int **. I have tryed everything I can think of which might work...