---
name: "ACE_New_Allocator"
section: "3"
platform: "linux"
package: "libace-doc"
version: "5.0.7-4"
release: "Debian 2.2 (Potato)"
platforms: ["linux"]
url: "https://new.carta.tech/ACE_New_Allocator"
---

# ACE\_New\_Allocator(3)

Defines a class that provided a simple implementation of memory allocation.

## NAME

ACE\_New\_Allocator -  Defines a class that provided a simple implementation of memory allocation.

## SYNOPSIS

```
#include <ace/Malloc.h>
class ACE_New_Allocator : public ACE_Allocator
{
  public:
    virtual void *malloc (size_t nbytes);
    virtual void *calloc (size_t nbytes, char initial_value = ' ');
    virtual void free (void *ptr);
    virtual int remove (void);
    virtual int bind (
        const char *name,
        void *pointer,
        int duplicates = 0
        );
    virtual int trybind (const char *name, void *&pointer);
    virtual int find (const char *name, void *&pointer);
    virtual int find (const char *name);
    virtual int unbind (const char *name);
    virtual int unbind (const char *name, void *&pointer);
    virtual int sync (ssize_t len = -1, int flags = MS_SYNC);
    virtual int sync (void *addr, size_t len, int flags = MS_SYNC);
    virtual int protect (ssize_t len = -1, int prot = PROT_RDWR);
    virtual int protect (
        void *addr,
        size_t len,
        int prot = PROT_RDWR
        );
    virtual void print_stats (void) const;
    virtual void dump (void) const;
};
```

## DESCRIPTION

This class uses the new/delete operators to allocate and free up memory.  Please note that the only methods that are supported are malloc and free. All other methods are no-ops. If you require this functionality, please use: ACE\_Allocator\_Adapter ACE\_Malloc ACE\_LOCAL\_MEMORY\_POOL, MUTEX  This will allow you to use the added functionality of bind/find/etc. while using the new/delete operators.

## PUBLIC MEMBERS

```
virtual void *malloc (size_t nbytes);
```

```
virtual void *calloc (size_t nbytes, char initial_value = ' ');
```

```
virtual void free (void *ptr);
```

```
virtual int remove (void);
```

```
virtual int bind (
    const char *name,
    void *pointer,
    int duplicates = 0
    );
```

```
virtual int trybind (const char *name, void *&pointer);
```

```
virtual int find (const char *name, void *&pointer);
```

```
virtual int find (const char *name);
```

```
virtual int unbind (const char *name);
```

```
virtual int unbind (const char *name, void *&pointer);
```

```
virtual int sync (ssize_t len = -1, int flags = MS_SYNC);
```

```
virtual int sync (void *addr, size_t len, int flags = MS_SYNC);
```

```
virtual int protect (ssize_t len = -1, int prot = PROT_RDWR);
```

```
virtual int protect (void *addr, size_t len, int prot = PROT_RDWR);
```

```
virtual void print_stats (void) const;
```

```
virtual void dump (void) const;
```

## AUTHOR

Doug Schmidt and Irfan Pyarali

## LIBRARY

ace
