Re: Dynamic Allocation Issues...



On Thu, 26 May 2005 12:01:04 +0530, "Muthukumar"
<muthu@xxxxxxxxxxxxxx> wrote:

>Dear Pals,
>
>Query 1:
>
>In my Win32 console application using Microsoft C compiler, I am using
>malloc() to allocate memory for the Pointer variables. These allocations are
>working very fine, but sometimes malloc() failed to allocate memory and
>gives Unhandled Exception error. Pointer variable has no allocated memory
>and hence it leads to Unhandled Exception.

When malloc fails, it returns NULL. You are supposed to check before
you use the returned value to reference memory.

>
>Could you please tell me in which cases malloc get fails to allocate memory?
>How to resolve this issue as a permanent?

It fails whenever it fails. It could be for lack of memory. It could
be for fragmented memory. ...

>
>Query 2:
> During the deallocation time using the free() , I am getting the "Debug
>Assertion failed" error in some cases. What might be the reason for getting
>this Error? Could you please give the better solution.

What is the value of the argument when this occurs.



<<Remove the del for email>>
.



Relevant Pages

  • Re: This calculation is just wrong / computer cant count!
    ... and I replied "new or malloc". ... It is not the fastest way to allocate memory". ... think that VirtualAlloc is faster than malloc has some serious issues, ... then there is no error only a precision limit. ...
    (microsoft.public.vc.mfc)
  • Re: difference between malloc and calloc?
    ... malloc(), and that's the opportunity for a tiny bit of sanity- checking. ... Here are two ways you might try to allocate memory to ... calloc() almost never. ... There is no special dispensation for overflow of nmemb * size; there is just the requirement for a NULL returned value. ...
    (comp.lang.c)
  • Re: difference between malloc and calloc?
    ... malloc(), and that's the opportunity for a tiny bit of sanity- checking. ... Here are two ways you might try to allocate memory to ... calloc() almost never. ... void *p = malloc; ...
    (comp.lang.c)
  • Dynamic Allocation Issues...
    ... malloc() to allocate memory for the Pointer variables. ... and hence it leads to Unhandled Exception. ...
    (microsoft.public.vc.ide_general)
  • Dynamic Allocation Problem.....
    ... malloc() to allocate memory for the Pointer variables. ... and hence it leads to Unhandled Exception. ...
    (microsoft.public.win32.programmer.messaging)