#include <ace/Malloc.h >
class ACE_Static_Allocator_Base : public ACE_Allocator {
public:ACE_Static_Allocator_Base (char *buffer, size_t size);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;protected:ACE_Static_Allocator_Base (void);char *buffer_;size_t size_;size_t offset_;};
POOL_SIZE of memory. Every
time malloc/calloc is called, it simply moves an internal
index forward and returns a pointer to the requested chunk.
All memory is allocated statically (typically via the
ACE_Static_Allocator template) and free is a no-op. This
behavior is useful for use-cases where all the memory
allocation needs are known in advance and no deletions ever
occur.
ACE_Static_Allocator_Base (char *buffer, size_t size);
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;
ACE_Static_Allocator_Base (void);
char *buffer_;
size_t size_;
size_t offset_;
buffer_.