NAME

ACE_Malloc - Define a C++ class that uses parameterized types to provide an extensible mechanism for encapsulating various of dynamic memory management strategies.

SYNOPSIS


#include <ace/Malloc_T.h>


template<class MEM_POOL, class LOCK>
class ACE_Malloc
{
  public:
    friend class ACE_Malloc_Iterator<MEM_POOL, LOCK>;
    typedef MEM_POOL MEMORY_POOL;
    ACE_Malloc (const char *pool_name = 0);
    ACE_Malloc (const char *pool_name, const char *lock_name);
    int remove (void);
    void *malloc (size_t nbytes);
    void *calloc (size_t nbytes, char initial_value = '  ');
    void free (void *ptr);
    MEMORY_POOL &memory_pool (void);
    int bind (const char *name, void *pointer, int duplicates = 0);
    int trybind (const char *name, void *&pointer);
    int find (const char *name, void *&pointer);
    int find (const char *name);
    int unbind (const char *name);
    int unbind (const char *name, void *&pointer);
    int sync (ssize_t len = -1, int flags = MS_SYNC);
    int sync (void *addr, size_t len, int flags = MS_SYNC);
    int protect (ssize_t len = -1, int prot = PROT_RDWR);
    int protect (void *addr, size_t len, int prot = PROT_RDWR);
    void print_stats (void);
    void dump (void) const;
    ACE_ALLOC_HOOK_DECLARE;
  private:
    int open (void);
    int shared_bind (const char *name, void *pointer);
    ACE_Name_Node *shared_find (const char *name);
    void *shared_malloc (size_t nbytes);
    void shared_free (void *ptr);
    MEMORY_POOL memory_pool_;
    ACE_Control_Block *cb_ptr_;
    LOCK lock_;
};

DESCRIPTION

This class can be configured flexibly with different MEMORY_POOL strategies and different types of LOCK strategies.

Initialization and termination methods.

ACE_Malloc (const char *pool_name = 0);
ACE_Malloc (const char *pool_name, const char *lock_name);
int remove (void);

Memory management

void *malloc (size_t nbytes);
void *calloc (size_t nbytes, char initial_value = '  ');
void free (void *ptr);
MEMORY_POOL &memory_pool (void);

Map manager like functions

int bind (const char *name, void *pointer, int duplicates = 0);
int trybind (const char *name, void *&pointer);
int find (const char *name, void *&pointer);
int find (const char *name);
int unbind (const char *name);
int unbind (const char *name, void *&pointer);

Protection and

sync" (i.e., flushing data to backing store)."
int sync (ssize_t len = -1, int flags = MS_SYNC);
int sync (void *addr, size_t len, int flags = MS_SYNC);
int protect (ssize_t len = -1, int prot = PROT_RDWR);
int protect (void *addr, size_t len, int prot = PROT_RDWR);
void print_stats (void);
void dump (void) const;
ACE_ALLOC_HOOK_DECLARE;

AUTHOR

Doug Schmidt and Irfan Pyarali

LIBRARY

ace