heap question

From: Janice (no_at_mail.com)
Date: 10/05/04


Date: Tue, 5 Oct 2004 11:52:16 +0800

If I create a space in the heap as the following, since the return pointer
is a local variable of the function, will the ptr and the space created in
the heap be removed when the function return?
Thanx

int* f(){
int* ptr;
ptr=calloc(9,sizeof(int));
return ptr;
}



Relevant Pages

  • Re: About C++ memory management
    ... int * ptr = new int; ... delete ptr; ... But if I copy this pointer like below should I also delete copied ... Foo ...
    (microsoft.public.vc.language)
  • Re: How to know the memory pointed by a ptr is freed?
    ... > perfectly valid). ... And you're probably assuming that an int* will fit ... > After the call to free, the value if ptr is indeterminate. ... > just copies the bits, but it could, for example, load the pointer ...
    (comp.lang.c)
  • Re: About C++ memory management
    ... int * ptr = new int; ... delete ptr; ... But if I copy this pointer like below should I also delete copied pointer? ... Foo ...
    (microsoft.public.vc.language)
  • Re: About C++ memory management
    ... I know that every pointer allocated by using new operator should be ... int * ptr = new int; ... delete ptr; ... Foo ...
    (microsoft.public.vc.language)
  • Re: How to know the memory pointed by a ptr is freed?
    ... And you're probably assuming that an int* will fit ... the value if ptr is indeterminate. ... just copies the bits, but it could, for example, load the pointer ... knowledge of the implementation (which could easily change with the ...
    (comp.lang.c)