Mail Archives: djgpp/1993/07/13/06:59:19
vincent AT physique DOT ens DOT fr (CROQUETTE Vincent) wrote:
> .... However,
> you have to be carefuill when allocating a 2D array with DJGPP: the
> allocation procedure work by chunk of power of 2 and if you
allocate a
> 512 element line, it needs 4 extra bytes for the record and thus
reserve
> a 1024 chunk ! Thus allocating a 512*512 array line by line will in
fact
> freeze 2 times the expected size, with big array this turns out to
be
> dramatic. One way to overcome this pb is to allocate the big chunk
> 512*512 in one operation and then map an array of pointers to
begining
> of lines.
There is no reason to use an array of pointers to the beginning of
lines if you use the proper C types. I believe this does what you
want:
#define NROWS 512
#define NCOLS 512
typedef int row[NCOLS];
...
row *my_matrix = (row *) malloc (sizeof (row) * NROWS);
my_matrix[123][456] = 7;
...
-Mat
- Raw text -