From 331b41f32e1071730d8fb949e4316eb8db2e2f30 Mon Sep 17 00:00:00 2001 From: schmidt Date: Wed, 8 Apr 1998 21:58:51 +0000 Subject: *** empty log message *** --- ace/Malloc_T.i | 126 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) (limited to 'ace/Malloc_T.i') diff --git a/ace/Malloc_T.i b/ace/Malloc_T.i index c6ca4e7fad0..04870225a64 100644 --- a/ace/Malloc_T.i +++ b/ace/Malloc_T.i @@ -184,3 +184,129 @@ ACE_Malloc::protect (void *addr, size_t len, int flags return this->memory_pool_.protect (addr, len, flags); } +template ACE_INLINE +ACE_Static_Allocator::ACE_Static_Allocator (void) + : offset_ (0) +{ +} + +template ACE_INLINE void * +ACE_Static_Allocator::malloc (size_t nbytes) +{ + if (this->offset_ + nbytes > POOL_SIZE) + { + errno = ENOMEM; + return 0; + } + else + { + char *ptr = &this->pool_[this->offset_]; + + this->offset_ += nbytes; + + return (void *) ptr; + } +} + +template ACE_INLINE void * +ACE_Static_Allocator::calloc (size_t nbytes, + char initial_value) +{ + void *ptr = this->malloc (nbytes); + + ACE_OS::memset (ptr, initial_value, nbytes); + return (void *) ptr; +} + +template ACE_INLINE void +ACE_Static_Allocator::free (void *ptr) +{ + // no-op! + // @@ We could check to see if ptr is within our pool?! +} + +template ACE_INLINE int +ACE_Static_Allocator::remove (void) +{ + return -1; +} + +template ACE_INLINE int +ACE_Static_Allocator::bind (const char *, void *, int) +{ + return -1; +} + +template ACE_INLINE int +ACE_Static_Allocator::trybind (const char *, void *&) +{ + return -1; +} + +template ACE_INLINE int +ACE_Static_Allocator::find (const char *, void *&) +{ + return -1; +} + +template ACE_INLINE int +ACE_Static_Allocator::find (const char *) +{ + return -1; +} + +template ACE_INLINE int +ACE_Static_Allocator::unbind (const char *) +{ + return -1; +} + +template ACE_INLINE int +ACE_Static_Allocator::unbind (const char *, void *&) +{ + return -1; +} + +template ACE_INLINE int +ACE_Static_Allocator::sync (ssize_t, int) +{ + return -1; +} + +template ACE_INLINE int +ACE_Static_Allocator::sync (void *, size_t, int) +{ + return -1; +} + +template ACE_INLINE int +ACE_Static_Allocator::protect (ssize_t, int) +{ + return -1; +} + +template ACE_INLINE int +ACE_Static_Allocator::protect (void *, size_t, int) +{ + return -1; +} + +#if defined (ACE_HAS_MALLOC_STATS) +template ACE_INLINE void +ACE_Static_Allocator::print_stats (void) const +{ +} +#endif /* ACE_HAS_MALLOC_STATS */ + +template ACE_INLINE void +ACE_Static_Allocator::dump (void) const +{ + ACE_TRACE ("ACE_Static_Allocator::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("\noffset_ = %d\n"), this->offset_)); + ACE_HEX_DUMP ((LM_DEBUG, this->pool_, POOL_SIZE)); + ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("\n"))); + + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +} -- cgit v1.2.1