Re: How to free dynamically allocated array?
- From: "Default User" <defaultuserbr@xxxxxxxxx>
- Date: 30 Aug 2005 15:34:29 GMT
Markus wrote:
> Hi,
>
> I have read the FAQ 6.16 on how to dynamically allocate a
> two-dimensional array.
>
> I do it like this:
>
> double** A = (double **)malloc(m * sizeof(double *));
> for(i = 0; i < m; i++)
> A[i] = (double *)malloc(n * sizeof(double));
>
> But how do I free it? I currently have only
>
> free(A);
>
> but I guess it is not enough.
>
> The FAQ is not clear about this.
The answer to 7.23 basically covers your question, although that's
about a dynamic structure.
http://www.eskimo.com/~scs/C-faq/q7.23.html
The advice there, one free() for every malloc() is the right one.
Brian
.
- References:
- How to free dynamically allocated array?
- From: Markus
- How to free dynamically allocated array?
- Prev by Date: Re: while (1) vs. for ( ;; )
- Next by Date: Re: object code from which compiler
- Previous by thread: Re: How to free dynamically allocated array?
- Next by thread: object code from which compiler
- Index(es):
Relevant Pages
|