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