#include <Malloc_Allocator.h>
Inheritance diagram for ACE_Static_Allocator_Base:


| Public Member Functions | |
| ACE_Static_Allocator_Base (char *buffer, size_t size) | |
| virtual void * | malloc (size_t nbytes) | 
| virtual void * | calloc (size_t nbytes, char initial_value= '\0') | 
| virtual void * | calloc (size_t n_elem, size_t elem_size, char initial_value= '\0') | 
| virtual void | free (void *ptr) | 
| Free  (must have been allocated by <ACE_Allocator::malloc>). | |
| virtual int | remove (void) | 
| Remove any resources associated with this memory manager. | |
| 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) | 
| Returns 0 if the name is in the mapping. -1, otherwise. | |
| 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 | dump (void) const | 
| Dump the state of the object. | |
| Protected Member Functions | |
| ACE_Static_Allocator_Base (void) | |
| Don't allow direct instantiations of this class. | |
| Protected Attributes | |
| char * | buffer_ | 
| Pointer to the buffer. | |
| size_t | size_ | 
| Size of the buffer. | |
| size_t | offset_ | 
| Pointer to the current offset in the . | |
This class manages a fixed-size of memory. Every time / 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 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.
Definition at line 100 of file Malloc_Allocator.h.
| 
 | ||||||||||||
| 
 Definition at line 8 of file Malloc_Allocator.inl. 
 | 
| 
 | 
| Don't allow direct instantiations of this class. 
 | 
| 
 | ||||||||||||||||
| Associate name with pointer. If duplicates == 0 then do not allow duplicate name/pointer associations, else if duplicates != 0 then allow duplicate name/pointer assocations. Returns 0 if successfully binds (1) a previously unbound name or (2) duplicates != 0, returns 1 if trying to bind a previously bound name and duplicates == 0, else returns -1 if a resource failure occurs. Implements ACE_Allocator. Definition at line 279 of file Malloc_Allocator.cpp. 
 00280 {
00281   return -1;
00282 }
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 257 of file Malloc_Allocator.cpp. References calloc(). 
 00260 {
00261   return this->calloc (n_elem * elem_size, initial_value);
00262 }
 | 
| 
 | ||||||||||||
| 
 Definition at line 247 of file Malloc_Allocator.cpp. References malloc(), and ACE_OS::memset(). Referenced by calloc(). 
 00249 {
00250   void *ptr = this->malloc (nbytes);
00251 
00252   ACE_OS::memset (ptr, initial_value, nbytes);
00253   return (void *) ptr;
00254 }
 | 
| 
 | 
| Dump the state of the object. 
 Implements ACE_Allocator. Definition at line 346 of file Malloc_Allocator.cpp. References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_HEX_DUMP, ACE_TEXT, ACE_TRACE, and LM_DEBUG. 
 00347 {
00348 #if defined (ACE_HAS_DUMP)
00349   ACE_TRACE ("ACE_Static_Allocator_Base::dump");
00350 
00351   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00352   ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\noffset_ = %d"), this->offset_));
00353   ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nsize_ = %d\n"), this->size_));
00354   ACE_HEX_DUMP ((LM_DEBUG, this->buffer_, this->size_));
00355   ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));
00356 
00357   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00358 #endif /* ACE_HAS_DUMP */
00359 }
 | 
| 
 | 
| Returns 0 if the name is in the mapping. -1, otherwise. 
 Implements ACE_Allocator. Definition at line 297 of file Malloc_Allocator.cpp. 
 00298 {
00299   return -1;
00300 }
 | 
| 
 | ||||||||||||
| Locate name and pass out parameter via pointer. If found, return 0, returns -1 if failure occurs. Implements ACE_Allocator. Definition at line 291 of file Malloc_Allocator.cpp. 
 00292 {
00293   return -1;
00294 }
 | 
| 
 | 
| Free (must have been allocated by <ACE_Allocator::malloc>). 
 Implements ACE_Allocator. Definition at line 265 of file Malloc_Allocator.cpp. References ACE_ASSERT, and buffer_. 
 00266 {
00267   // Check to see if ptr is within our pool?!
00268   ACE_UNUSED_ARG (ptr);
00269   ACE_ASSERT (ptr >= this->buffer_ && ptr < this->buffer_ + this->size_);
00270 }
 | 
| 
 | 
| 
 Definition at line 229 of file Malloc_Allocator.cpp. References buffer_, and offset_. Referenced by calloc(). 
 00230 {
00231   if (this->offset_ + nbytes > this->size_)
00232     {
00233       errno = ENOMEM;
00234       return 0;
00235     }
00236   else
00237     {
00238       // Record the current offset, increment the offset by the number
00239       // of bytes requested, and return the original offset.
00240       char *ptr = &this->buffer_[this->offset_];
00241       this->offset_ += nbytes;
00242       return (void *) ptr;
00243     }
00244 }
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 333 of file Malloc_Allocator.cpp. 
 00334 {
00335   return -1;
00336 }
 | 
| 
 | ||||||||||||
| Change the protection of the pages of the mapped region to prot starting at <this->base_addr_> up to len bytes. If len == -1 then change protection of all pages in the mapped region. Implements ACE_Allocator. Definition at line 327 of file Malloc_Allocator.cpp. References ssize_t. 
 00328 {
00329   return -1;
00330 }
 | 
| 
 | 
| Remove any resources associated with this memory manager. 
 Implements ACE_Allocator. Definition at line 273 of file Malloc_Allocator.cpp. 
 00274 {
00275   return -1;
00276 }
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 321 of file Malloc_Allocator.cpp. 
 00322 {
00323   return -1;
00324 }
 | 
| 
 | ||||||||||||
| 
Sync len bytes of the memory region to the backing store starting at  Implements ACE_Allocator. Definition at line 315 of file Malloc_Allocator.cpp. References ssize_t. 
 00316 {
00317   return -1;
00318 }
 | 
| 
 | ||||||||||||
| Associate name with pointer. Does not allow duplicate name/pointer associations. Returns 0 if successfully binds (1) a previously unbound name, 1 if trying to bind a previously bound name, or returns -1 if a resource failure occurs. When this call returns pointer's value will always reference the void * that name is associated with. Thus, if the caller needs to use pointer (e.g., to free it) a copy must be maintained by the caller. Implements ACE_Allocator. Definition at line 285 of file Malloc_Allocator.cpp. 
 00286 {
00287   return -1;
00288 }
 | 
| 
 | ||||||||||||
| Break any association of name. Returns the value of pointer in case the caller needs to deallocate memory. Implements ACE_Allocator. Definition at line 309 of file Malloc_Allocator.cpp. 
 00310 {
00311   return -1;
00312 }
 | 
| 
 | 
| Unbind (remove) the name from the map. Don't return the pointer to the caller Implements ACE_Allocator. Definition at line 303 of file Malloc_Allocator.cpp. 
 00304 {
00305   return -1;
00306 }
 | 
| 
 | 
| Pointer to the buffer. 
 Definition at line 129 of file Malloc_Allocator.h. | 
| 
 | 
| Pointer to the current offset in the . 
 Definition at line 135 of file Malloc_Allocator.h. Referenced by malloc(). | 
| 
 | 
| Size of the buffer. 
 Definition at line 132 of file Malloc_Allocator.h. | 
 1.3.6
 
1.3.6