harmodrew
10th August 2010, 11:54
Hello!
In the following code
cell struct declaration:
struct cell {
int i, j;
};
cell *Cells= (cell*) malloc (sizeof(cell));
int i, j, k=0;
for (i=0; i<nrow; i++)
for (j=0; j<ncol; j++)
{
k++;
qRealloc(Cells, sizeof(cell) * k);
Cells[k-1].i=i;
Cells[k-1].j=j;
}
I need to create a dynamic matrix with qRealloc (and I've tried even with realloc() ). if I run this code in VS 6.0 it's ok, but in Qt Creator it raises a segmentation fault error. Moreover if I declare the Cells matrix as a static one (so cell Cells[100]; and comment the realloc) all goes good (of course).
Is there a known bug on realloc and qRealloc functions in Qt 4? Or I'm trying to do something wrong?
thanks
In the following code
cell struct declaration:
struct cell {
int i, j;
};
cell *Cells= (cell*) malloc (sizeof(cell));
int i, j, k=0;
for (i=0; i<nrow; i++)
for (j=0; j<ncol; j++)
{
k++;
qRealloc(Cells, sizeof(cell) * k);
Cells[k-1].i=i;
Cells[k-1].j=j;
}
I need to create a dynamic matrix with qRealloc (and I've tried even with realloc() ). if I run this code in VS 6.0 it's ok, but in Qt Creator it raises a segmentation fault error. Moreover if I declare the Cells matrix as a static one (so cell Cells[100]; and comment the realloc) all goes good (of course).
Is there a known bug on realloc and qRealloc functions in Qt 4? Or I'm trying to do something wrong?
thanks