Re: C++ allocation in arena ?

New Message Reply Date view Thread view Subject view Author view

bmcquear++at++dw3f.ess.harris.com
Mon, 11 Sep 95 08:41:48 -0400


On Sep 11, 9:10am, Lionel Maiaux wrote:
> Subject: C++ allocation in arena ?
> Hi,
>
> I want to use standard C++ allocation (new, delete) but I want these
> allocations to be in Performer arena.
> I suppose it's very simple with Performer 2.0 but I am not a beta tester and
I
> must do it now (so, with 1.2).
> Any idea ?
>
>-- End of excerpt from Lionel Maiaux

Lionel,

  Here's one way to do it in 1.2 (excerpt from vrfly, which can be
found at sgigate++at++sgi.com). You can use this as a parent class to all of
your classes you want allocated from the arena, or you can overload the
operator in each class.

////////////////////////////////////////////

#ifndef __PFNEW__
#define __PFNEW__

#include <pf.h>
#include <stdlib.h>

class pfnew
{
 public:
   
  void * operator new(size_t);
  void operator delete(void *);
};

#endif
///////////////////////////////////////////

#include "pfnew.h"
#include <pf.h>

void *
 pfnew::operator new(size_t s)
{
  void * buff = pfMalloc(s, pfGetSharedArena());
  return buff;
}

void
 pfnew::operator delete(void * p)
{
    pfFree(p);
}

-----------------------------------------------------------
Bruce McQueary | Phone 407-984-5964 (Office)
Harris Corporation, ISD | 407-984-6813 (Lab)
P.O. Box 98000 | Fax 407-984-6323
W3-3207 | email: bmcquear++at++harris.com
Melbourne, FL 32902 |
-----------------------------------------------------------
  


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:51:52 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.