RE:malloc.h -> mmalloc.h

From: Masaharu Goto (MXJ02154@nifty.ne.jp)
Date: Sun Jul 18 1999 - 23:16:01 MEST


Hello,

>hello ppl
>im having problems with memory allocation
>i would like to know what are the default functions and parameters
>for the standard <malloc.h> C library functions in root :)
>
>thanks

I am not quite sure the true meaning of your question. I try to answer
as much as I can.

Cint and ROOT/CINT support following ANSI C standard function.

   void *malloc(size_t size);
   void free(void* ptr);

and C++ new/delete operators.

   void* operator new(size_t size);
   void* operator new(size_t size,void* arena);
   void  operator delete(void* ptr);

For memory allocation, you can use either of following.

 1) double *pdbl = (double*)malloc(sizeof(double));
    free((void*)pdbl);

 2) double *pdbl = new double;
    delete pdbl;

 3) char buf[100];
    double *pdbl = new((void*)buf) double;
    // do not delete pbl in this case

This is almost full C/C++ spec. Limitation is that you can not overload
operator new/delete in interpreted code.

Thank you
Masaharu Goto



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:35 MET