Re: obj function hello()



On Sat, 10 Feb 2007 11:55:04 GMT, in comp.lang.c , rpbg123@xxxxxxxxx
(Roland Pibinger) wrote:

On Fri, 09 Feb 2007 14:43:45 +1300, Ian Collins wrote:
Ian Collins wrote:
int main(void) {
Obj* obj = malloc( sizeof obj );

Oops, malloc( sizeof *obj );

Why malloc?

In C, what else would you use to allocate memory than one of the
*alloc family?

Why a memory leak?

What memory leak?
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
.



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)
  • Re: Dynamic Allocation Problem.....
    ... malloc() to allocate memory for the Pointer variables. ... version you will see some debug output in this case. ...
    (microsoft.public.de.vc)
  • Re: malloc() for struct member
    ... Is it OK to allocate memory by mallocor callocfor a ... > int a; ... >struct mystruct myobject; ... Don't cast the return from malloc. ...
    (comp.lang.c)