summaryrefslogtreecommitdiff
path: root/ace/Malloc_Allocator.i
diff options
context:
space:
mode:
authordoccvs <doccvs@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2000-10-13 01:21:57 +0000
committerdoccvs <doccvs@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2000-10-13 01:21:57 +0000
commit7160e530fc43393be47a655ce100e1fc125dc6d9 (patch)
tree05479c9b98febc8a45460fec03442753e5a81f0e /ace/Malloc_Allocator.i
parent6aeced075745800ab99d5386488da57b1afa9b67 (diff)
downloadATCD-7160e530fc43393be47a655ce100e1fc125dc6d9.tar.gz
ChangeLogTag: Thu Oct 12 18:19:46 2000 Priyanka Gontla <pgontla@ece.uci.edu>
Diffstat (limited to 'ace/Malloc_Allocator.i')
-rw-r--r--ace/Malloc_Allocator.i225
1 files changed, 225 insertions, 0 deletions
diff --git a/ace/Malloc_Allocator.i b/ace/Malloc_Allocator.i
new file mode 100644
index 00000000000..31e2abc9b2b
--- /dev/null
+++ b/ace/Malloc_Allocator.i
@@ -0,0 +1,225 @@
+// $Id$
+
+ACE_INLINE void *
+ACE_New_Allocator::malloc (size_t nbytes)
+{
+ char *ptr = 0;
+
+ if (nbytes > 0)
+ ACE_NEW_RETURN (ptr, char[nbytes], 0);
+ return (void *) ptr;
+}
+
+ACE_INLINE void *
+ACE_New_Allocator::calloc (size_t nbytes,
+ char initial_value)
+{
+ char *ptr = 0;
+
+ ACE_NEW_RETURN (ptr, char[nbytes], 0);
+
+ ACE_OS::memset (ptr, initial_value, nbytes);
+ return (void *) ptr;
+}
+
+ACE_INLINE void
+ACE_New_Allocator::free (void *ptr)
+{
+ delete [] (char *) ptr;
+}
+
+ACE_INLINE int
+ACE_New_Allocator::remove (void)
+{
+ return -1;
+}
+
+ACE_INLINE int
+ACE_New_Allocator::bind (const char *, void *, int)
+{
+ return -1;
+}
+
+ACE_INLINE int
+ACE_New_Allocator::trybind (const char *, void *&)
+{
+ return -1;
+}
+
+ACE_INLINE int
+ACE_New_Allocator::find (const char *, void *&)
+{
+ return -1;
+}
+
+ACE_INLINE int
+ACE_New_Allocator::find (const char *)
+{
+ return -1;
+}
+
+ACE_INLINE int
+ACE_New_Allocator::unbind (const char *)
+{
+ return -1;
+}
+
+ACE_INLINE int
+ACE_New_Allocator::unbind (const char *, void *&)
+{
+ return -1;
+}
+
+ACE_INLINE int
+ACE_New_Allocator::sync (ssize_t, int)
+{
+ return -1;
+}
+
+ACE_INLINE int
+ACE_New_Allocator::sync (void *, size_t, int)
+{
+ return -1;
+}
+
+ACE_INLINE int
+ACE_New_Allocator::protect (ssize_t, int)
+{
+ return -1;
+}
+
+ACE_INLINE int
+ACE_New_Allocator::protect (void *, size_t, int)
+{
+ return -1;
+}
+
+#if defined (ACE_HAS_MALLOC_STATS)
+ACE_INLINE void
+ACE_New_Allocator::print_stats (void) const
+{
+}
+#endif /* ACE_HAS_MALLOC_STATS */
+
+ACE_INLINE void
+ACE_New_Allocator::dump (void) const
+{
+}
+
+ACE_INLINE void *
+ACE_Static_Allocator_Base::malloc (size_t nbytes)
+{
+ if (this->offset_ + nbytes > this->size_)
+ {
+ errno = ENOMEM;
+ return 0;
+ }
+ else
+ {
+ // Record the current offset, increment the offset by the number
+ // of bytes requested, and return the original offset.
+ char *ptr = &this->buffer_[this->offset_];
+ this->offset_ += nbytes;
+ return (void *) ptr;
+ }
+}
+
+ACE_INLINE void *
+ACE_Static_Allocator_Base::calloc (size_t nbytes,
+ char initial_value)
+{
+ void *ptr = this->malloc (nbytes);
+
+ ACE_OS::memset (ptr, initial_value, nbytes);
+ return (void *) ptr;
+}
+
+ACE_INLINE void
+ACE_Static_Allocator_Base::free (void *ptr)
+{
+ // Check to see if ptr is within our pool?!
+ ACE_UNUSED_ARG (ptr);
+ ACE_ASSERT (ptr >= this->buffer_ && ptr < this->buffer_ + this->size_);
+}
+
+ACE_INLINE int
+ACE_Static_Allocator_Base::remove (void)
+{
+ return -1;
+}
+
+ACE_INLINE int
+ACE_Static_Allocator_Base::bind (const char *, void *, int)
+{
+ return -1;
+}
+
+ACE_INLINE int
+ACE_Static_Allocator_Base::trybind (const char *, void *&)
+{
+ return -1;
+}
+
+ACE_INLINE int
+ACE_Static_Allocator_Base::find (const char *, void *&)
+{
+ return -1;
+}
+
+ACE_INLINE int
+ACE_Static_Allocator_Base::find (const char *)
+{
+ return -1;
+}
+
+ACE_INLINE int
+ACE_Static_Allocator_Base::unbind (const char *)
+{
+ return -1;
+}
+
+ACE_INLINE int
+ACE_Static_Allocator_Base::unbind (const char *, void *&)
+{
+ return -1;
+}
+
+ACE_INLINE int
+ACE_Static_Allocator_Base::sync (ssize_t, int)
+{
+ return -1;
+}
+
+ACE_INLINE int
+ACE_Static_Allocator_Base::sync (void *, size_t, int)
+{
+ return -1;
+}
+
+ACE_INLINE int
+ACE_Static_Allocator_Base::protect (ssize_t, int)
+{
+ return -1;
+}
+
+ACE_INLINE int
+ACE_Static_Allocator_Base::protect (void *, size_t, int)
+{
+ return -1;
+}
+
+#if defined (ACE_HAS_MALLOC_STATS)
+ACE_INLINE void
+ACE_Static_Allocator_Base::print_stats (void) const
+{
+}
+#endif /* ACE_HAS_MALLOC_STATS */
+
+ACE_INLINE
+ACE_Static_Allocator_Base::ACE_Static_Allocator_Base (char *buffer,
+ size_t size)
+ : buffer_ (buffer),
+ size_ (size),
+ offset_ (0)
+{
+}