Re: [Dev-C++] Multidimensional arrays and memory leaks
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: <tay...@dd...> - 2004-08-10 23:15:08
|
Thanks to your advice I was able to go a little further with my program.
However, when I tried to assign values to the array, the debugger gives me a
message telling about a segment fragmentation problem and then crashes.
The way I assign the values is the following:
for (i=0;i<FL[0];i++)
{
numbuque[i][0]=0; // tipo de buque - rango de esloras menor
numbuque[i][1]=i; // numero de llegada del buque
}
Any suggestion? Thanks,
Jorge
> First, allocate the "pointers" array, and then allocate the arrays
> inside. In C:
>
> number=(float **)malloc(2*sizeof(float *));
> ....
> int i;
> for(i=0;i<50000;i++){
> *(number+i)=(float *)malloc(sizeof(float));
> ...
> }
>
> and so on.
>
> tay...@dd... escribió:
>
> >Hi,
> >
> >Since I tried to use a 2D array "number[50000][2]" I started to have
ran> dom
> >crashes at run time and debugging.
> >
> >I guess this is a memory handling problem (what do you think?). Thus, I
> tried
> >to put the array in the heap (would that help?). However I tried many
wa> y to do
> >it without success.
> >
> >I declared the array in the header of a class as:
> >
> >float number[][];
> >
> >Then I tried to put it in the heap using GlobalAlloc in the
constructor.>
> >
> >
> >Could anybody give me a hand? Thanks a lot.
> >
> >Jorge
> >
> >
> >---------------------------------------------
> >This message was sent using Endymion MailMan.
> >http://www.endymion.com/products/mailman/
> >
> >
> >
> >
> >-------------------------------------------------------
> >SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
> >100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
> >Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
> >http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
> >_______________________________________________
> >Dev-cpp-users mailing list
> >Dev...@li...
> >TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> >https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
> >
> >
> >
>
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
> 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
> Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
> http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
---------------------------------------------
This message was sent using Endymion MailMan.
http://www.endymion.com/products/mailman/
|