00001
00002
00003 ACE_INLINE void *
00004 ACE_New_Allocator::malloc (size_t nbytes)
00005 {
00006 char *ptr = 0;
00007
00008 if (nbytes > 0)
00009 ACE_NEW_RETURN (ptr, char[nbytes], 0);
00010 return (void *) ptr;
00011 }
00012
00013 ACE_INLINE void *
00014 ACE_New_Allocator::calloc (size_t nbytes,
00015 char initial_value)
00016 {
00017 char *ptr = 0;
00018
00019 ACE_NEW_RETURN (ptr, char[nbytes], 0);
00020
00021 ACE_OS::memset (ptr, initial_value, nbytes);
00022 return (void *) ptr;
00023 }
00024
00025 ACE_INLINE void *
00026 ACE_New_Allocator::calloc (size_t n_elem, size_t elem_size, char initial_value)
00027 {
00028 return ACE_New_Allocator::calloc (n_elem * elem_size, initial_value);
00029 }
00030
00031 ACE_INLINE void
00032 ACE_New_Allocator::free (void *ptr)
00033 {
00034 delete [] (char *) ptr;
00035 }
00036
00037 ACE_INLINE int
00038 ACE_New_Allocator::remove (void)
00039 {
00040 ACE_NOTSUP_RETURN (-1);
00041 }
00042
00043 ACE_INLINE int
00044 ACE_New_Allocator::bind (const char *, void *, int)
00045 {
00046 ACE_NOTSUP_RETURN (-1);
00047 }
00048
00049 ACE_INLINE int
00050 ACE_New_Allocator::trybind (const char *, void *&)
00051 {
00052 ACE_NOTSUP_RETURN (-1);
00053 }
00054
00055 ACE_INLINE int
00056 ACE_New_Allocator::find (const char *, void *&)
00057 {
00058 ACE_NOTSUP_RETURN (-1);
00059 }
00060
00061 ACE_INLINE int
00062 ACE_New_Allocator::find (const char *)
00063 {
00064 ACE_NOTSUP_RETURN (-1);
00065 }
00066
00067 ACE_INLINE int
00068 ACE_New_Allocator::unbind (const char *)
00069 {
00070 ACE_NOTSUP_RETURN (-1);
00071 }
00072
00073 ACE_INLINE int
00074 ACE_New_Allocator::unbind (const char *, void *&)
00075 {
00076 ACE_NOTSUP_RETURN (-1);
00077 }
00078
00079 ACE_INLINE int
00080 ACE_New_Allocator::sync (ssize_t, int)
00081 {
00082 ACE_NOTSUP_RETURN (-1);
00083 }
00084
00085 ACE_INLINE int
00086 ACE_New_Allocator::sync (void *, size_t, int)
00087 {
00088 ACE_NOTSUP_RETURN (-1);
00089 }
00090
00091 ACE_INLINE int
00092 ACE_New_Allocator::protect (ssize_t, int)
00093 {
00094 ACE_NOTSUP_RETURN (-1);
00095 }
00096
00097 ACE_INLINE int
00098 ACE_New_Allocator::protect (void *, size_t, int)
00099 {
00100 ACE_NOTSUP_RETURN (-1);
00101 }
00102
00103 #if defined (ACE_HAS_MALLOC_STATS)
00104 ACE_INLINE void
00105 ACE_New_Allocator::print_stats (void) const
00106 {
00107 }
00108 #endif
00109
00110 ACE_INLINE void
00111 ACE_New_Allocator::dump (void) const
00112 {
00113 }
00114
00115 ACE_INLINE void *
00116 ACE_Static_Allocator_Base::malloc (size_t nbytes)
00117 {
00118 if (this->offset_ + nbytes > this->size_)
00119 {
00120 errno = ENOMEM;
00121 return 0;
00122 }
00123 else
00124 {
00125
00126
00127 char *ptr = &this->buffer_[this->offset_];
00128 this->offset_ += nbytes;
00129 return (void *) ptr;
00130 }
00131 }
00132
00133 ACE_INLINE void *
00134 ACE_Static_Allocator_Base::calloc (size_t nbytes,
00135 char initial_value)
00136 {
00137 void *ptr = this->malloc (nbytes);
00138
00139 ACE_OS::memset (ptr, initial_value, nbytes);
00140 return (void *) ptr;
00141 }
00142
00143 ACE_INLINE void *
00144 ACE_Static_Allocator_Base::calloc (size_t n_elem,
00145 size_t elem_size,
00146 char initial_value)
00147 {
00148 return this->calloc (n_elem * elem_size, initial_value);
00149 }
00150
00151 ACE_INLINE void
00152 ACE_Static_Allocator_Base::free (void *ptr)
00153 {
00154
00155 ACE_UNUSED_ARG (ptr);
00156 ACE_ASSERT (ptr >= this->buffer_ && ptr < this->buffer_ + this->size_);
00157 }
00158
00159 ACE_INLINE int
00160 ACE_Static_Allocator_Base::remove (void)
00161 {
00162 return -1;
00163 }
00164
00165 ACE_INLINE int
00166 ACE_Static_Allocator_Base::bind (const char *, void *, int)
00167 {
00168 return -1;
00169 }
00170
00171 ACE_INLINE int
00172 ACE_Static_Allocator_Base::trybind (const char *, void *&)
00173 {
00174 return -1;
00175 }
00176
00177 ACE_INLINE int
00178 ACE_Static_Allocator_Base::find (const char *, void *&)
00179 {
00180 return -1;
00181 }
00182
00183 ACE_INLINE int
00184 ACE_Static_Allocator_Base::find (const char *)
00185 {
00186 return -1;
00187 }
00188
00189 ACE_INLINE int
00190 ACE_Static_Allocator_Base::unbind (const char *)
00191 {
00192 return -1;
00193 }
00194
00195 ACE_INLINE int
00196 ACE_Static_Allocator_Base::unbind (const char *, void *&)
00197 {
00198 return -1;
00199 }
00200
00201 ACE_INLINE int
00202 ACE_Static_Allocator_Base::sync (ssize_t, int)
00203 {
00204 return -1;
00205 }
00206
00207 ACE_INLINE int
00208 ACE_Static_Allocator_Base::sync (void *, size_t, int)
00209 {
00210 return -1;
00211 }
00212
00213 ACE_INLINE int
00214 ACE_Static_Allocator_Base::protect (ssize_t, int)
00215 {
00216 return -1;
00217 }
00218
00219 ACE_INLINE int
00220 ACE_Static_Allocator_Base::protect (void *, size_t, int)
00221 {
00222 return -1;
00223 }
00224
00225 #if defined (ACE_HAS_MALLOC_STATS)
00226 ACE_INLINE void
00227 ACE_Static_Allocator_Base::print_stats (void) const
00228 {
00229 }
00230 #endif
00231
00232 ACE_INLINE
00233 ACE_Static_Allocator_Base::ACE_Static_Allocator_Base (char *buffer,
00234 size_t size)
00235 : buffer_ (buffer),
00236 size_ (size),
00237 offset_ (0)
00238 {
00239 }