BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bdlma_buffermanager.h
Go to the documentation of this file.
1/// @file bdlma_buffermanager.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bdlma_buffermanager.h -*-C++-*-
8#ifndef INCLUDED_BDLMA_BUFFERMANAGER
9#define INCLUDED_BDLMA_BUFFERMANAGER
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bdlma_buffermanager bdlma_buffermanager
15/// @brief Provide a memory manager that manages an external buffer.
16/// @addtogroup bdl
17/// @{
18/// @addtogroup bdlma
19/// @{
20/// @addtogroup bdlma_buffermanager
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bdlma_buffermanager-purpose"> Purpose</a>
25/// * <a href="#bdlma_buffermanager-classes"> Classes </a>
26/// * <a href="#bdlma_buffermanager-description"> Description </a>
27/// * <a href="#bdlma_buffermanager-usage"> Usage </a>
28/// * <a href="#bdlma_buffermanager-example-1-basic-usage"> Example 1: Basic Usage </a>
29///
30/// # Purpose {#bdlma_buffermanager-purpose}
31/// Provide a memory manager that manages an external buffer.
32///
33/// # Classes {#bdlma_buffermanager-classes}
34///
35/// - bdlma::BufferManager: memory manager that manages an external buffer
36///
37/// @see bdlma_bufferimputil, bdlma_bufferedsequentialallocator
38///
39/// # Description {#bdlma_buffermanager-description}
40/// This component provides a memory manager ("buffer manager"),
41/// `bdlma::BufferManager`, that dispenses heterogeneous memory blocks (of
42/// varying, user-specified sizes) from an external buffer. A `BufferManager`
43/// has a similar interface to a sequential pool in that the two methods
44/// `allocate` and `release` are provided.
45///
46/// In addition to the `allocate` method, a less safe but faster variation,
47/// `allocateRaw`, is provided to support memory allocation: If there is
48/// insufficient memory remaining in the buffer to satisfy an allocation
49/// request, `allocate` will return 0 while `allocateRaw` will result in
50/// undefined behavior.
51///
52/// The behavior of `allocate` and `allocateRaw` illustrates the main difference
53/// between this buffer manager and a sequential pool. Once the external buffer
54/// runs out of memory, the buffer manager does not self-replenish, whereas a
55/// sequential pool will do so.
56///
57/// The `release` method resets the buffer manager such that the memory within
58/// the entire external buffer will be made available for subsequent
59/// allocations. Note that individually allocated memory blocks cannot be
60/// separately deallocated.
61///
62/// `bdlma::BufferManager` is typically used for fast and efficient memory
63/// allocation, when the user knows in advance the maximum amount of memory
64/// needed.
65///
66/// ## Usage {#bdlma_buffermanager-usage}
67///
68///
69/// This section illustrates intended use of this component.
70///
71/// ### Example 1: Basic Usage {#bdlma_buffermanager-example-1-basic-usage}
72///
73///
74/// Suppose that we need to detect whether there are at least `n` duplicates
75/// within an array of integers. Furthermore, suppose that speed is a concern
76/// and we need the fastest possible implementation. A natural solution will be
77/// to use a hash table. To further optimize for speed, we can use a custom
78/// memory manager, such as `bdlma::BufferManager`, to speed up memory
79/// allocations.
80///
81/// First, let's define the structure of a node inside our custom hash table
82/// structure:
83/// @code
84/// /// This struct represents a node within a hash table.
85/// struct my_Node {
86///
87/// // DATA
88/// int d_value; // integer value this node holds
89/// int d_count; // number of occurrences of this integer value
90/// my_Node *d_next_p; // pointer to the next node
91///
92/// // CREATORS
93///
94/// /// Create a node having the specified `value` that refers to the
95/// /// specified `next` node.
96/// my_Node(int value, my_Node *next);
97/// };
98///
99/// // CREATORS
100/// my_Node::my_Node(int value, my_Node *next)
101/// : d_value(value)
102/// , d_count(1)
103/// , d_next_p(next)
104/// {
105/// }
106/// @endcode
107/// Note that `sizeof(my_Node) == 12` when compiled in 32-bit mode, and
108/// `sizeof(my_Node) == 16` when compiled in 64-bit mode. This difference
109/// affects the amount of memory used under different alignment strategies (see
110/// @ref bsls_alignment for more details on alignment strategies).
111///
112/// We can then define the structure of our specialized hash table used for
113/// integer counting:
114/// @code
115/// /// This class represents a hash table that is used to keep track of the
116/// /// number of occurrences of various integers. Note that this is a
117/// /// highly specialized class that uses a `bdlma::BufferManager` with
118/// /// sufficient memory for memory allocations.
119/// class my_IntegerCountingHashTable {
120///
121/// // DATA
122/// my_Node **d_nodeArray; // array of `my_Node` pointers
123///
124/// int d_size; // size of the node array
125///
126/// bdlma::BufferManager *d_buffer; // buffer manager (held, not
127/// // owned)
128///
129/// public:
130/// // CLASS METHODS
131///
132/// /// Return the memory required by a `my_IntegerCountingHashTable`
133/// /// that has the specified `tableLength` and `numNodes`.
134/// static int calculateBufferSize(int tableLength, int numNodes);
135///
136/// // CREATORS
137///
138/// /// Create a hash table of the specified `size`, using the specified
139/// /// `buffer` to supply memory. The behavior is undefined unless
140/// /// `0 < size`, `buffer` is non-zero, and `buffer` has sufficient
141/// /// memory to support all memory allocations required.
142/// my_IntegerCountingHashTable(int size, bdlma::BufferManager *buffer);
143///
144/// // ...
145///
146/// // MANIPULATORS
147///
148/// /// Insert the specified `value` with a count of 1 into this hash
149/// /// table if `value` does not currently exist in the hash table, and
150/// /// increment the count for `value` otherwise. Return the number of
151/// /// occurrences of `value` in this hash table.
152/// int insert(int value);
153///
154/// // ...
155/// };
156/// @endcode
157/// The implementation of the rest of `my_IntegerCountingHashTable` is elided as
158/// the class method `calculateBufferSize`, constructor, and the `insert` method
159/// alone are sufficient to illustrate the use of `bdlma::BufferManager`:
160/// @code
161/// // CLASS METHODS
162/// int my_IntegerCountingHashTable::calculateBufferSize(int tableLength,
163/// int numNodes)
164/// {
165/// return static_cast<int>(tableLength * sizeof(my_Node *)
166/// + numNodes * sizeof(my_Node)
167/// + bsls::AlignmentUtil::BSLS_MAX_ALIGNMENT);
168/// }
169/// @endcode
170/// Note that, in case the allocated buffer is not aligned, the size calculation
171/// includes a "fudge" factor equivalent to the maximum alignment requirement of
172/// the platform.
173/// @code
174/// // CREATORS
175/// my_IntegerCountingHashTable::my_IntegerCountingHashTable(
176/// int size,
177/// bdlma::BufferManager *buffer)
178/// : d_size(size)
179/// , d_buffer(buffer)
180/// {
181/// // 'd_buffer' must have sufficient memory to satisfy the allocation
182/// // request (as specified by the constructor's contract).
183///
184/// d_nodeArray = static_cast<my_Node **>(
185/// d_buffer->allocate(d_size * sizeof(my_Node *)));
186///
187/// bsl::memset(d_nodeArray, 0, d_size * sizeof(my_Node *));
188/// }
189///
190/// // MANIPULATORS
191/// int my_IntegerCountingHashTable::insert(int value)
192/// {
193/// // Naive hash function using only mod.
194///
195/// const int hashValue = value % d_size;
196/// my_Node **tmp = &d_nodeArray[hashValue];
197///
198/// while (*tmp) {
199/// if ((*tmp)->d_value != value) {
200/// tmp = &((*tmp)->d_next_p);
201/// }
202/// else {
203/// return ++((*tmp)->d_count); // RETURN
204/// }
205/// }
206///
207/// // 'allocate' does not trigger dynamic memory allocation. Therefore,
208/// // we don't have to worry about exceptions and can use placement 'new'
209/// // directly with 'allocate'. 'd_buffer' must have sufficient memory to
210/// // satisfy the allocation request (as specified by the constructor's
211/// // contract).
212///
213/// *tmp = new(d_buffer->allocate(sizeof(my_Node))) my_Node(value, *tmp);
214///
215/// return 1;
216/// }
217/// @endcode
218/// Note that `bdlma::BufferManager` is used to allocate memory blocks of
219/// heterogeneous sizes. In the constructor, memory is allocated for the node
220/// array. In `insert`, memory is allocated for the nodes.
221///
222/// Finally, in the following `detectNOccurrences` function, we can use the hash
223/// table class to detect whether any integer value occurs at least `n` times
224/// within a specified array:
225/// @code
226/// /// Return `true` if any integer value in the specified `array` having
227/// /// the specified `length` appears at least the specified `n` times, and
228/// /// `false` otherwise.
229/// bool detectNOccurrences(int n, const int *array, int length)
230/// {
231/// const int MAX_SIZE = my_IntegerCountingHashTable::
232/// calculateBufferSize(length, length);
233/// @endcode
234/// We then allocate an external buffer to be used by `bdlma::BufferManager`.
235/// Normally, this buffer will be created on the program stack if we know the
236/// length in advance (for example, if we specify in the contract of this
237/// function that we only handle arrays having a length of up to 10,000
238/// integers). However, to make this function more general, we decide to
239/// allocate the memory dynamically. This approach is still much more efficient
240/// than using the default allocator, say, to allocate memory for individual
241/// nodes within `insert`, since we need only a single dynamic allocation,
242/// versus separate dynamic allocations for every single node:
243/// @code
244/// bslma::Allocator *allocator = bslma::Default::defaultAllocator();
245/// char *buffer = static_cast<char *>(allocator->allocate(MAX_SIZE));
246/// @endcode
247/// We use a `bslma::DeallocatorGuard` to automatically deallocate the buffer
248/// when the function ends:
249/// @code
250/// bslma::DeallocatorGuard<bslma::Allocator> guard(buffer, allocator);
251///
252/// bdlma::BufferManager bufferManager(buffer, MAX_SIZE);
253/// my_IntegerCountingHashTable table(length, &bufferManager);
254///
255/// while (--length >= 0) {
256/// if (n == table.insert(array[length])) {
257/// return true; // RETURN
258/// }
259/// }
260///
261/// return false;
262/// }
263/// @endcode
264/// Note that the calculation of `MAX_SIZE` assumes natural alignment. If
265/// maximum alignment is used instead, a larger buffer is needed since each node
266/// object will then be maximally aligned, which takes up 16 bytes each instead
267/// of 12 bytes on a 32-bit architecture. On a 64-bit architecture, there will
268/// be no savings using natural alignment since the size of a node will be 16
269/// bytes regardless.
270/// @}
271/** @} */
272/** @} */
273
274/** @addtogroup bdl
275 * @{
276 */
277/** @addtogroup bdlma
278 * @{
279 */
280/** @addtogroup bdlma_buffermanager
281 * @{
282 */
283
284#include <bdlscm_version.h>
285
286#include <bsls_alignment.h>
287#include <bsls_alignmentutil.h>
288#include <bsls_assert.h>
289#include <bsls_performancehint.h>
290#include <bsls_platform.h>
291#include <bsls_review.h>
292#include <bsls_types.h>
293
294
295namespace bdlma {
296
297 // ===================
298 // class BufferManager
299 // ===================
300
301/// This class implements a buffer manager that dispenses heterogeneous
302/// blocks of memory (of varying, user-specified sizes) from an external
303/// buffer whose address and size are optionally supplied at construction.
304/// If an allocation request exceeds the remaining free memory space in the
305/// external buffer, the allocation request returns 0 if `allocate` is used, or results in undefined behavior if `allocateRaw` is used.
306///
307/// \note Note that in
308/// no event will the buffer manager attempt to deallocate the external
309/// buffer.
310///
311/// See @ref bdlma_buffermanager
313
314 // DATA
315 char *d_buffer_p; // external buffer (held, not
316 // owned)
317
318 bsls::Types::size_type d_bufferSize; // size (in bytes) of external
319 // buffer
320
321 bsls::Types::IntPtr d_cursor; // offset to next available
322 // byte in buffer
323
324 unsigned char d_alignmentAndMask; // a mask used during the
325 // alignment calculation
326
327 unsigned char d_alignmentOrMask; // a mask used during the
328 // alignment calculation
329
330 private:
331 // NOT IMPLEMENTED
333 BufferManager& operator=(const BufferManager&);
334
335 public:
336 // CREATORS
337
338 /// Create a buffer manager for allocating memory blocks. Optionally
339 /// specify an alignment `strategy` used to align allocated memory
340 /// blocks. If `strategy` is not specified, natural alignment is used.
341 /// A default constructed buffer manager is unable to allocate any
342 /// memory until an external buffer is provided by calling the
343 /// `replaceBuffer` method.
344 explicit
347
348 /// Create a buffer manager for allocating memory blocks from the
349 /// specified external `buffer` having the specified `bufferSize` (in
350 /// bytes). Optionally specify an alignment `strategy` used to align
351 /// allocated memory blocks. If `strategy` is not specified, natural alignment is used.
352 ///
353 /// \pre The behavior is undefined unless
354 /// `0 < bufferSize` and `buffer` has at least `bufferSize` bytes.
356 char *buffer,
359
360 /// Destroy this buffer manager.
362
363 // MANIPULATORS
364
365 /// Return the address of a contiguous block of memory of the specified
366 /// `size` (in bytes) on success, according to the alignment strategy
367 /// specified at construction. If `size` is 0 or the allocation request
368 /// exceeds the remaining free memory space in the external buffer, no
369 /// memory is allocated and 0 is returned.
371
372 /// Return the address of a contiguous block of memory of the specified
373 /// `size` (in bytes) according to the alignment strategy specified at construction.
374 ///
375 /// \pre The behavior is undefined unless the allocation
376 /// request does not exceed the remaining free memory space in the
377 /// external buffer, `0 < size`, and this object is currently managing a
378 /// buffer.
380
381 /// Destroy the specified `object`.
382 /// \note Note that memory associated with
383 /// `object` is not deallocated because there is no `deallocate` method
384 /// in `BufferManager`.
385 template <class TYPE>
386 void deleteObjectRaw(const TYPE *object);
387
388 /// Destroy the specified `object`.
389 /// \note Note that this method has the same
390 /// effect as the `deleteObjectRaw` method (since no deallocation is
391 /// involved), and exists for consistency with a pool interface.
392 template <class TYPE>
393 void deleteObject(const TYPE *object);
394
395 /// Increase the amount of memory allocated at the specified `address`
396 /// from the original `size` (in bytes) to also include the maximum
397 /// amount remaining in the buffer. Return the amount of memory
398 /// available at `address` after expanding, or `size` if the memory at
399 /// `address` cannot be expanded. This method can only `expand` the
400 /// memory block returned by the most recent `allocate` or `allocateRaw`
401 /// request from this buffer manager, and otherwise has no effect.
402 ///
403 /// \pre The behavior is undefined unless the memory at `address` was originally
404 /// allocated by this buffer manager, the size of the memory at
405 /// `address` is `size`, and `release` was not called after allocating
406 /// the memory at `address`.
408
409 /// Replace the buffer currently managed by this object with the
410 /// specified `newBuffer` of the specified `newBufferSize` (in bytes);
411 /// return the address of the previously held buffer, or 0 if this
412 /// object currently manages no buffer. The replaced buffer (if any) is
413 /// removed from the management of this object with no effect on the
414 /// outstanding allocated memory blocks. Subsequent allocations will
415 /// allocate memory from the beginning of the new external buffer.
416 ///
417 /// \pre The behavior is undefined unless `0 < newBufferSize` and `newBuffer` has
418 /// at least `newBufferSize` bytes.
419 char *replaceBuffer(char *newBuffer, bsls::Types::size_type newBufferSize);
420
421 /// Release all memory currently allocated through this buffer manager.
422 /// After this call, the external buffer managed by this object is
423 /// retained. Subsequent allocations will allocate memory from the
424 /// beginning of the external buffer (if any).
425 void release();
426
427 /// Reset this buffer manager to its default constructed state, except
428 /// retain the alignment strategy in effect at the time of construction.
429 /// The currently managed buffer (if any) is removed from the management
430 /// of this object with no effect on the outstanding allocated memory
431 /// blocks.
432 void reset();
433
434 /// Reduce the amount of memory allocated at the specified `address` of
435 /// the specified `originalSize` (in bytes) to the specified `newSize`
436 /// (in bytes). Return `newSize` after truncating, or `originalSize` if
437 /// the memory at `address` cannot be truncated. This method can only
438 /// `truncate` the memory block returned by the most recent `allocate`
439 /// or `allocateRaw` request from this object, and otherwise has no effect.
440 ///
441 /// \pre The behavior is undefined unless the memory at `address`
442 /// was originally allocated by this buffer manager, the size of the
443 /// memory at `address` is `originalSize`, `newSize <= originalSize`,
444 /// `0 <= newSize`, and `release` was not called after allocating the
445 /// memory at `address`.
447 bsls::Types::size_type originalSize,
448 bsls::Types::size_type newSize);
449
450 // ACCESSORS
451
452 /// Return the alignment strategy passed to this object at
453 /// construction.
455
456 /// Return an address providing modifiable access to the buffer
457 /// currently managed by this object, or 0 if this object currently
458 /// manages no buffer.
459 char *buffer() const;
460
461 /// Return the size (in bytes) of the buffer currently managed by this
462 /// object, or 0 if this object currently manages no buffer.
464
465 /// Return the minimum non-negative integer that, when added to the
466 /// numerical value of the specified `address`, yields the alignment as
467 /// per the `alignmentStrategy` provided at construction for an allocation of the specified `size`.
468 ///
469 /// \note Note that if `0 == size` and
470 /// natural alignment was provided at construction, the result of this
471 /// method is identical to the result for `0 == size` and maximal
472 /// alignment.
473 int calculateAlignmentOffsetFromSize(const void *address,
474 bsls::Types::size_type size) const;
475
476 /// Return `true` if there is sufficient memory space in the buffer to
477 /// allocate a contiguous memory block of the specified `size` (in
478 /// bytes) after taking the alignment strategy into consideration, and `false` otherwise.
479 ///
480 /// \pre The behavior is undefined unless `0 < size`, and
481 /// this object is currently managing a buffer.
483};
484
485// ============================================================================
486// INLINE DEFINITIONS
487// ============================================================================
488
489 // -------------------
490 // class BufferManager
491 // -------------------
492
493// CREATORS
494inline
495BufferManager::BufferManager(bsls::Alignment::Strategy strategy)
496: d_buffer_p(0)
497, d_bufferSize(0)
498, d_cursor(0)
499, d_alignmentAndMask( strategy != bsls::Alignment::BSLS_MAXIMUM
500 ? bsls::AlignmentUtil::BSLS_MAX_ALIGNMENT - 1
501 : 0)
502, d_alignmentOrMask( strategy != bsls::Alignment::BSLS_BYTEALIGNED
503 ? bsls::AlignmentUtil::BSLS_MAX_ALIGNMENT
504 : 1)
505{
506}
507
508inline
509BufferManager::BufferManager(char *buffer,
510 bsls::Types::size_type bufferSize,
512: d_buffer_p(buffer)
513, d_bufferSize(bufferSize)
514, d_cursor(0)
515, d_alignmentAndMask( strategy != bsls::Alignment::BSLS_MAXIMUM
516 ? bsls::AlignmentUtil::BSLS_MAX_ALIGNMENT - 1
517 : 0)
518, d_alignmentOrMask( strategy != bsls::Alignment::BSLS_BYTEALIGNED
519 ? bsls::AlignmentUtil::BSLS_MAX_ALIGNMENT
520 : 1)
521{
524}
525
526inline
528{
529 BSLS_ASSERT(0 <= d_cursor);
530 BSLS_ASSERT(static_cast<bsls::Types::size_type>(d_cursor) <= d_bufferSize);
531 BSLS_ASSERT( (0 != d_buffer_p && 0 < d_bufferSize)
532 || (0 == d_buffer_p && 0 == d_bufferSize));
533}
534
535// MANIPULATORS
536inline
538{
539 BSLS_ASSERT_SAFE(0 <= d_cursor);
540 BSLS_ASSERT_SAFE(static_cast<bsls::Types::size_type>(d_cursor)
541 <= d_bufferSize);
542
543 char *address = d_buffer_p + d_cursor;
544
545 int offset = calculateAlignmentOffsetFromSize(address, size);
546
547 bsls::Types::IntPtr cursor = d_cursor + offset + size;
549 static_cast<bsls::Types::size_type>(cursor) <= d_bufferSize)
551 d_cursor = cursor;
552 return address + offset; // RETURN
553 }
554
555 return 0;
556}
557
558inline
560{
561 BSLS_ASSERT_SAFE(0 < size);
562 BSLS_ASSERT_SAFE(0 <= d_cursor);
563 BSLS_ASSERT_SAFE(static_cast<bsls::Types::size_type>(d_cursor)
564 <= d_bufferSize);
565 BSLS_ASSERT_SAFE(d_buffer_p);
566
567 char *address = d_buffer_p + d_cursor;
568
569 int offset = calculateAlignmentOffsetFromSize(address, size);
570
571 d_cursor = d_cursor + offset + size;
572 return address + offset;
573}
574
575template <class TYPE>
576inline
577void BufferManager::deleteObjectRaw(const TYPE *object)
578{
579 if (0 != object) {
580#ifndef BSLS_PLATFORM_CMP_SUN
581 object->~TYPE();
582#else
583 const_cast<TYPE *>(object)->~TYPE();
584#endif
585 }
586}
587
588template <class TYPE>
589inline
590void BufferManager::deleteObject(const TYPE *object)
591{
592 deleteObjectRaw(object);
593}
594
595inline
596char *BufferManager::replaceBuffer(char *newBuffer,
597 bsls::Types::size_type newBufferSize)
598{
599 BSLS_ASSERT(newBuffer);
600 BSLS_ASSERT(0 < newBufferSize);
601
602 char *oldBuffer = d_buffer_p;
603 d_buffer_p = newBuffer;
604 d_bufferSize = newBufferSize;
605 d_cursor = 0;
606
607 return oldBuffer;
608}
609
610inline
612{
613 d_cursor = 0;
614}
615
616inline
618{
619 d_buffer_p = 0;
620 d_bufferSize = 0;
621 d_cursor = 0;
622}
623
624// ACCESSORS
625inline
627{
628 return 0 == d_alignmentAndMask ? bsls::Alignment::BSLS_MAXIMUM
629 : 1 == d_alignmentOrMask
632}
633
634inline
636{
637 return d_buffer_p;
638}
639
640inline
642{
643 return d_bufferSize;
644}
645
646inline
648 const void *address,
649 bsls::Types::size_type size) const
650{
651 bsls::Types::size_type alignment =
652 (size & static_cast<bsls::Types::size_type>(d_alignmentAndMask)) |
653 d_alignmentOrMask;
654
655 // Clear all but lowest order set bit (note the cast avoids a MSVC warning
656 // related to negating an unsigned type).
657
658 alignment &= -static_cast<bsls::Types::IntPtr>(alignment);
659
660 return static_cast<int>(
661 (alignment - reinterpret_cast<bsls::Types::size_type>(address))
662 & (alignment - 1));
663}
664
665inline
667{
668 BSLS_ASSERT(0 < size);
669 BSLS_ASSERT(d_buffer_p);
670 BSLS_ASSERT(0 <= d_cursor);
671 BSLS_ASSERT(static_cast<bsls::Types::size_type>(d_cursor)
672 <= d_bufferSize);
673
674 char *address = d_buffer_p + d_cursor;
675
676 int offset = calculateAlignmentOffsetFromSize(address, size);
677
678 return d_cursor + offset + size <= d_bufferSize;
679}
680
681} // close package namespace
682
683
684#endif
685
686// ----------------------------------------------------------------------------
687// Copyright 2016 Bloomberg Finance L.P.
688//
689// Licensed under the Apache License, Version 2.0 (the "License");
690// you may not use this file except in compliance with the License.
691// You may obtain a copy of the License at
692//
693// http://www.apache.org/licenses/LICENSE-2.0
694//
695// Unless required by applicable law or agreed to in writing, software
696// distributed under the License is distributed on an "AS IS" BASIS,
697// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
698// See the License for the specific language governing permissions and
699// limitations under the License.
700// ----------------------------- END-OF-FILE ----------------------------------
701
702/** @} */
703/** @} */
704/** @} */
Definition bdlma_buffermanager.h:312
char * replaceBuffer(char *newBuffer, bsls::Types::size_type newBufferSize)
Definition bdlma_buffermanager.h:596
bsls::Types::size_type truncate(void *address, bsls::Types::size_type originalSize, bsls::Types::size_type newSize)
void reset()
Definition bdlma_buffermanager.h:617
~BufferManager()
Destroy this buffer manager.
Definition bdlma_buffermanager.h:527
void * allocateRaw(bsls::Types::size_type size)
Definition bdlma_buffermanager.h:559
bool hasSufficientCapacity(bsls::Types::size_type size) const
Definition bdlma_buffermanager.h:666
int calculateAlignmentOffsetFromSize(const void *address, bsls::Types::size_type size) const
Definition bdlma_buffermanager.h:647
void deleteObject(const TYPE *object)
Definition bdlma_buffermanager.h:590
bsls::Types::size_type bufferSize() const
Definition bdlma_buffermanager.h:641
void release()
Definition bdlma_buffermanager.h:611
bsls::Alignment::Strategy alignmentStrategy() const
Definition bdlma_buffermanager.h:626
void deleteObjectRaw(const TYPE *object)
Definition bdlma_buffermanager.h:577
bsls::Types::size_type expand(void *address, bsls::Types::size_type size)
char * buffer() const
Definition bdlma_buffermanager.h:635
void * allocate(bsls::Types::size_type size)
Definition bdlma_buffermanager.h:537
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1976
#define BSLS_ASSERT_SAFE(X)
Definition bsls_assert.h:1917
#define BSLS_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition bsls_ident.h:238
#define BSLS_PERFORMANCEHINT_PREDICT_LIKELY(expr)
Definition bsls_performancehint.h:451
Definition bdlma_alignedallocator.h:278
Definition bdlt_iso8601util.h:707
Strategy
Types of alignment strategy.
Definition bsls_alignment.h:241
@ BSLS_NATURAL
Definition bsls_alignment.h:248
@ BSLS_MAXIMUM
Definition bsls_alignment.h:244
@ BSLS_BYTEALIGNED
Definition bsls_alignment.h:252
std::size_t size_type
Definition bsls_types.h:126
std::ptrdiff_t IntPtr
Definition bsls_types.h:132