1280ddee8SMarshall Clow //===-------------------------- cxa_vector.cpp ---------------------------===// 2280ddee8SMarshall Clow // 3*57b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*57b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information. 5*57b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6280ddee8SMarshall Clow // 7280ddee8SMarshall Clow // 8280ddee8SMarshall Clow // This file implements the "Array Construction and Destruction APIs" 9c5f7e6feSJonathan Roelofs // http://mentorembedded.github.io/cxx-abi/abi.html#array-ctor 10280ddee8SMarshall Clow // 11280ddee8SMarshall Clow //===----------------------------------------------------------------------===// 12280ddee8SMarshall Clow 13280ddee8SMarshall Clow #include "cxxabi.h" 14280ddee8SMarshall Clow 15280ddee8SMarshall Clow #include <exception> // for std::terminate 16280ddee8SMarshall Clow 17280ddee8SMarshall Clow namespace __cxxabiv1 { 18280ddee8SMarshall Clow 195b2d125cSNick Lewycky #if 0 20280ddee8SMarshall Clow #pragma mark --Helper routines and classes -- 215b2d125cSNick Lewycky #endif 22280ddee8SMarshall Clow 23280ddee8SMarshall Clow namespace { 24280ddee8SMarshall Clow inline static size_t __get_element_count ( void *p ) { 25280ddee8SMarshall Clow return static_cast <size_t *> (p)[-1]; 26280ddee8SMarshall Clow } 27280ddee8SMarshall Clow 28280ddee8SMarshall Clow inline static void __set_element_count ( void *p, size_t element_count ) { 29280ddee8SMarshall Clow static_cast <size_t *> (p)[-1] = element_count; 30280ddee8SMarshall Clow } 31280ddee8SMarshall Clow 32280ddee8SMarshall Clow 33280ddee8SMarshall Clow // A pair of classes to simplify exception handling and control flow. 34280ddee8SMarshall Clow // They get passed a block of memory in the constructor, and unless the 35280ddee8SMarshall Clow // 'release' method is called, they deallocate the memory in the destructor. 36be2eced4SHoward Hinnant // Preferred usage is to allocate some memory, attach it to one of these objects, 37280ddee8SMarshall Clow // and then, when all the operations to set up the memory block have succeeded, 38280ddee8SMarshall Clow // call 'release'. If any of the setup operations fail, or an exception is 39280ddee8SMarshall Clow // thrown, then the block is automatically deallocated. 40280ddee8SMarshall Clow // 41280ddee8SMarshall Clow // The only difference between these two classes is the signature for the 42280ddee8SMarshall Clow // deallocation function (to match new2/new3 and delete2/delete3. 43280ddee8SMarshall Clow class st_heap_block2 { 44280ddee8SMarshall Clow public: 45280ddee8SMarshall Clow typedef void (*dealloc_f)(void *); 46280ddee8SMarshall Clow 47280ddee8SMarshall Clow st_heap_block2 ( dealloc_f dealloc, void *ptr ) 48280ddee8SMarshall Clow : dealloc_ ( dealloc ), ptr_ ( ptr ), enabled_ ( true ) {} 49280ddee8SMarshall Clow ~st_heap_block2 () { if ( enabled_ ) dealloc_ ( ptr_ ) ; } 50280ddee8SMarshall Clow void release () { enabled_ = false; } 51280ddee8SMarshall Clow 52280ddee8SMarshall Clow private: 53280ddee8SMarshall Clow dealloc_f dealloc_; 54280ddee8SMarshall Clow void *ptr_; 55280ddee8SMarshall Clow bool enabled_; 56280ddee8SMarshall Clow }; 57280ddee8SMarshall Clow 58280ddee8SMarshall Clow class st_heap_block3 { 59280ddee8SMarshall Clow public: 60280ddee8SMarshall Clow typedef void (*dealloc_f)(void *, size_t); 61280ddee8SMarshall Clow 62280ddee8SMarshall Clow st_heap_block3 ( dealloc_f dealloc, void *ptr, size_t size ) 63280ddee8SMarshall Clow : dealloc_ ( dealloc ), ptr_ ( ptr ), size_ ( size ), enabled_ ( true ) {} 64280ddee8SMarshall Clow ~st_heap_block3 () { if ( enabled_ ) dealloc_ ( ptr_, size_ ) ; } 65280ddee8SMarshall Clow void release () { enabled_ = false; } 66280ddee8SMarshall Clow 67280ddee8SMarshall Clow private: 68280ddee8SMarshall Clow dealloc_f dealloc_; 69280ddee8SMarshall Clow void *ptr_; 70280ddee8SMarshall Clow size_t size_; 71280ddee8SMarshall Clow bool enabled_; 72280ddee8SMarshall Clow }; 73280ddee8SMarshall Clow 74280ddee8SMarshall Clow class st_cxa_cleanup { 75280ddee8SMarshall Clow public: 76280ddee8SMarshall Clow typedef void (*destruct_f)(void *); 77280ddee8SMarshall Clow 78280ddee8SMarshall Clow st_cxa_cleanup ( void *ptr, size_t &idx, size_t element_size, destruct_f destructor ) 79280ddee8SMarshall Clow : ptr_ ( ptr ), idx_ ( idx ), element_size_ ( element_size ), 80280ddee8SMarshall Clow destructor_ ( destructor ), enabled_ ( true ) {} 81280ddee8SMarshall Clow ~st_cxa_cleanup () { 82280ddee8SMarshall Clow if ( enabled_ ) 83280ddee8SMarshall Clow __cxa_vec_cleanup ( ptr_, idx_, element_size_, destructor_ ); 84280ddee8SMarshall Clow } 85280ddee8SMarshall Clow 86280ddee8SMarshall Clow void release () { enabled_ = false; } 87280ddee8SMarshall Clow 88280ddee8SMarshall Clow private: 89280ddee8SMarshall Clow void *ptr_; 90280ddee8SMarshall Clow size_t &idx_; 91280ddee8SMarshall Clow size_t element_size_; 92280ddee8SMarshall Clow destruct_f destructor_; 93280ddee8SMarshall Clow bool enabled_; 94280ddee8SMarshall Clow }; 95280ddee8SMarshall Clow 96280ddee8SMarshall Clow class st_terminate { 97280ddee8SMarshall Clow public: 98280ddee8SMarshall Clow st_terminate ( bool enabled = true ) : enabled_ ( enabled ) {} 99280ddee8SMarshall Clow ~st_terminate () { if ( enabled_ ) std::terminate (); } 100280ddee8SMarshall Clow void release () { enabled_ = false; } 101280ddee8SMarshall Clow private: 102280ddee8SMarshall Clow bool enabled_ ; 103280ddee8SMarshall Clow }; 104280ddee8SMarshall Clow } 105280ddee8SMarshall Clow 1065b2d125cSNick Lewycky #if 0 107280ddee8SMarshall Clow #pragma mark --Externally visible routines-- 1085b2d125cSNick Lewycky #endif 109280ddee8SMarshall Clow 110280ddee8SMarshall Clow extern "C" { 111280ddee8SMarshall Clow 112280ddee8SMarshall Clow // Equivalent to 113280ddee8SMarshall Clow // 114280ddee8SMarshall Clow // __cxa_vec_new2(element_count, element_size, padding_size, constructor, 115280ddee8SMarshall Clow // destructor, &::operator new[], &::operator delete[]) 11612315edfSSaleem Abdulrasool _LIBCXXABI_FUNC_VIS void * 11712315edfSSaleem Abdulrasool __cxa_vec_new(size_t element_count, size_t element_size, size_t padding_size, 11812315edfSSaleem Abdulrasool void (*constructor)(void *), void (*destructor)(void *)) { 119280ddee8SMarshall Clow return __cxa_vec_new2 ( element_count, element_size, padding_size, 120280ddee8SMarshall Clow constructor, destructor, &::operator new [], &::operator delete [] ); 121280ddee8SMarshall Clow } 122280ddee8SMarshall Clow 123280ddee8SMarshall Clow 124280ddee8SMarshall Clow 125280ddee8SMarshall Clow // Given the number and size of elements for an array and the non-negative 126280ddee8SMarshall Clow // size of prefix padding for a cookie, allocate space (using alloc) for 127280ddee8SMarshall Clow // the array preceded by the specified padding, initialize the cookie if 128280ddee8SMarshall Clow // the padding is non-zero, and call the given constructor on each element. 129280ddee8SMarshall Clow // Return the address of the array proper, after the padding. 130280ddee8SMarshall Clow // 131280ddee8SMarshall Clow // If alloc throws an exception, rethrow the exception. If alloc returns 132280ddee8SMarshall Clow // NULL, return NULL. If the constructor throws an exception, call 133280ddee8SMarshall Clow // destructor for any already constructed elements, and rethrow the 134280ddee8SMarshall Clow // exception. If the destructor throws an exception, call std::terminate. 135280ddee8SMarshall Clow // 136280ddee8SMarshall Clow // The constructor may be NULL, in which case it must not be called. If the 137280ddee8SMarshall Clow // padding_size is zero, the destructor may be NULL; in that case it must 138280ddee8SMarshall Clow // not be called. 139280ddee8SMarshall Clow // 140280ddee8SMarshall Clow // Neither alloc nor dealloc may be NULL. 14112315edfSSaleem Abdulrasool _LIBCXXABI_FUNC_VIS void * 14212315edfSSaleem Abdulrasool __cxa_vec_new2(size_t element_count, size_t element_size, size_t padding_size, 14312315edfSSaleem Abdulrasool void (*constructor)(void *), void (*destructor)(void *), 14412315edfSSaleem Abdulrasool void *(*alloc)(size_t), void (*dealloc)(void *)) { 145280ddee8SMarshall Clow const size_t heap_size = element_count * element_size + padding_size; 146280ddee8SMarshall Clow char * const heap_block = static_cast<char *> ( alloc ( heap_size )); 147280ddee8SMarshall Clow char *vec_base = heap_block; 148280ddee8SMarshall Clow 149280ddee8SMarshall Clow if ( NULL != vec_base ) { 150280ddee8SMarshall Clow st_heap_block2 heap ( dealloc, heap_block ); 151280ddee8SMarshall Clow 152280ddee8SMarshall Clow // put the padding before the array elements 153280ddee8SMarshall Clow if ( 0 != padding_size ) { 154280ddee8SMarshall Clow vec_base += padding_size; 155280ddee8SMarshall Clow __set_element_count ( vec_base, element_count ); 156280ddee8SMarshall Clow } 157280ddee8SMarshall Clow 158280ddee8SMarshall Clow // Construct the elements 159280ddee8SMarshall Clow __cxa_vec_ctor ( vec_base, element_count, element_size, constructor, destructor ); 160280ddee8SMarshall Clow heap.release (); // We're good! 161280ddee8SMarshall Clow } 162280ddee8SMarshall Clow 163280ddee8SMarshall Clow return vec_base; 164280ddee8SMarshall Clow } 165280ddee8SMarshall Clow 166280ddee8SMarshall Clow 167280ddee8SMarshall Clow // Same as __cxa_vec_new2 except that the deallocation function takes both 168280ddee8SMarshall Clow // the object address and its size. 16912315edfSSaleem Abdulrasool _LIBCXXABI_FUNC_VIS void * 17012315edfSSaleem Abdulrasool __cxa_vec_new3(size_t element_count, size_t element_size, size_t padding_size, 17112315edfSSaleem Abdulrasool void (*constructor)(void *), void (*destructor)(void *), 17212315edfSSaleem Abdulrasool void *(*alloc)(size_t), void (*dealloc)(void *, size_t)) { 173280ddee8SMarshall Clow const size_t heap_size = element_count * element_size + padding_size; 174280ddee8SMarshall Clow char * const heap_block = static_cast<char *> ( alloc ( heap_size )); 175280ddee8SMarshall Clow char *vec_base = heap_block; 176280ddee8SMarshall Clow 177280ddee8SMarshall Clow if ( NULL != vec_base ) { 178280ddee8SMarshall Clow st_heap_block3 heap ( dealloc, heap_block, heap_size ); 179280ddee8SMarshall Clow 180280ddee8SMarshall Clow // put the padding before the array elements 181280ddee8SMarshall Clow if ( 0 != padding_size ) { 182280ddee8SMarshall Clow vec_base += padding_size; 183280ddee8SMarshall Clow __set_element_count ( vec_base, element_count ); 184280ddee8SMarshall Clow } 185280ddee8SMarshall Clow 186280ddee8SMarshall Clow // Construct the elements 187280ddee8SMarshall Clow __cxa_vec_ctor ( vec_base, element_count, element_size, constructor, destructor ); 188280ddee8SMarshall Clow heap.release (); // We're good! 189280ddee8SMarshall Clow } 190280ddee8SMarshall Clow 191280ddee8SMarshall Clow return vec_base; 192280ddee8SMarshall Clow } 193280ddee8SMarshall Clow 194280ddee8SMarshall Clow 195280ddee8SMarshall Clow // Given the (data) addresses of a destination and a source array, an 196280ddee8SMarshall Clow // element count and an element size, call the given copy constructor to 197280ddee8SMarshall Clow // copy each element from the source array to the destination array. The 198280ddee8SMarshall Clow // copy constructor's arguments are the destination address and source 199280ddee8SMarshall Clow // address, respectively. If an exception occurs, call the given destructor 200280ddee8SMarshall Clow // (if non-NULL) on each copied element and rethrow. If the destructor 201280ddee8SMarshall Clow // throws an exception, call terminate(). The constructor and or destructor 202280ddee8SMarshall Clow // pointers may be NULL. If either is NULL, no action is taken when it 203280ddee8SMarshall Clow // would have been called. 204280ddee8SMarshall Clow 20512315edfSSaleem Abdulrasool _LIBCXXABI_FUNC_VIS void __cxa_vec_cctor(void *dest_array, void *src_array, 20612315edfSSaleem Abdulrasool size_t element_count, 20712315edfSSaleem Abdulrasool size_t element_size, 20812315edfSSaleem Abdulrasool void (*constructor)(void *, void *), 209242d67b6SSaleem Abdulrasool void (*destructor)(void *)) { 210280ddee8SMarshall Clow if ( NULL != constructor ) { 211280ddee8SMarshall Clow size_t idx = 0; 212280ddee8SMarshall Clow char *src_ptr = static_cast<char *>(src_array); 213280ddee8SMarshall Clow char *dest_ptr = static_cast<char *>(dest_array); 214280ddee8SMarshall Clow st_cxa_cleanup cleanup ( dest_array, idx, element_size, destructor ); 215280ddee8SMarshall Clow 216280ddee8SMarshall Clow for ( idx = 0; idx < element_count; 217280ddee8SMarshall Clow ++idx, src_ptr += element_size, dest_ptr += element_size ) 218280ddee8SMarshall Clow constructor ( dest_ptr, src_ptr ); 219280ddee8SMarshall Clow cleanup.release (); // We're good! 220280ddee8SMarshall Clow } 221280ddee8SMarshall Clow } 222280ddee8SMarshall Clow 223280ddee8SMarshall Clow 224280ddee8SMarshall Clow // Given the (data) address of an array, not including any cookie padding, 225280ddee8SMarshall Clow // and the number and size of its elements, call the given constructor on 226280ddee8SMarshall Clow // each element. If the constructor throws an exception, call the given 227280ddee8SMarshall Clow // destructor for any already-constructed elements, and rethrow the 228280ddee8SMarshall Clow // exception. If the destructor throws an exception, call terminate(). The 229280ddee8SMarshall Clow // constructor and/or destructor pointers may be NULL. If either is NULL, 230280ddee8SMarshall Clow // no action is taken when it would have been called. 23112315edfSSaleem Abdulrasool _LIBCXXABI_FUNC_VIS void 23212315edfSSaleem Abdulrasool __cxa_vec_ctor(void *array_address, size_t element_count, size_t element_size, 23312315edfSSaleem Abdulrasool void (*constructor)(void *), void (*destructor)(void *)) { 234280ddee8SMarshall Clow if ( NULL != constructor ) { 235280ddee8SMarshall Clow size_t idx; 236280ddee8SMarshall Clow char *ptr = static_cast <char *> ( array_address ); 237280ddee8SMarshall Clow st_cxa_cleanup cleanup ( array_address, idx, element_size, destructor ); 238280ddee8SMarshall Clow 239280ddee8SMarshall Clow // Construct the elements 240280ddee8SMarshall Clow for ( idx = 0; idx < element_count; ++idx, ptr += element_size ) 241280ddee8SMarshall Clow constructor ( ptr ); 242280ddee8SMarshall Clow cleanup.release (); // We're good! 243280ddee8SMarshall Clow } 244280ddee8SMarshall Clow } 245280ddee8SMarshall Clow 246280ddee8SMarshall Clow // Given the (data) address of an array, the number of elements, and the 247280ddee8SMarshall Clow // size of its elements, call the given destructor on each element. If the 248280ddee8SMarshall Clow // destructor throws an exception, rethrow after destroying the remaining 249280ddee8SMarshall Clow // elements if possible. If the destructor throws a second exception, call 250280ddee8SMarshall Clow // terminate(). The destructor pointer may be NULL, in which case this 251280ddee8SMarshall Clow // routine does nothing. 25212315edfSSaleem Abdulrasool _LIBCXXABI_FUNC_VIS void __cxa_vec_dtor(void *array_address, 25312315edfSSaleem Abdulrasool size_t element_count, 25412315edfSSaleem Abdulrasool size_t element_size, 25512315edfSSaleem Abdulrasool void (*destructor)(void *)) { 256280ddee8SMarshall Clow if ( NULL != destructor ) { 257280ddee8SMarshall Clow char *ptr = static_cast <char *> (array_address); 258280ddee8SMarshall Clow size_t idx = element_count; 259280ddee8SMarshall Clow st_cxa_cleanup cleanup ( array_address, idx, element_size, destructor ); 260280ddee8SMarshall Clow { 2617fdfd5d2SHoward Hinnant st_terminate exception_guard (__cxa_uncaught_exception ()); 262280ddee8SMarshall Clow ptr += element_count * element_size; // one past the last element 263280ddee8SMarshall Clow 264280ddee8SMarshall Clow while ( idx-- > 0 ) { 265280ddee8SMarshall Clow ptr -= element_size; 266280ddee8SMarshall Clow destructor ( ptr ); 267280ddee8SMarshall Clow } 268280ddee8SMarshall Clow exception_guard.release (); // We're good ! 269280ddee8SMarshall Clow } 270280ddee8SMarshall Clow cleanup.release (); // We're still good! 271280ddee8SMarshall Clow } 272280ddee8SMarshall Clow } 273280ddee8SMarshall Clow 274280ddee8SMarshall Clow // Given the (data) address of an array, the number of elements, and the 275280ddee8SMarshall Clow // size of its elements, call the given destructor on each element. If the 276280ddee8SMarshall Clow // destructor throws an exception, call terminate(). The destructor pointer 277280ddee8SMarshall Clow // may be NULL, in which case this routine does nothing. 27812315edfSSaleem Abdulrasool _LIBCXXABI_FUNC_VIS void __cxa_vec_cleanup(void *array_address, 27912315edfSSaleem Abdulrasool size_t element_count, 28012315edfSSaleem Abdulrasool size_t element_size, 28112315edfSSaleem Abdulrasool void (*destructor)(void *)) { 282280ddee8SMarshall Clow if ( NULL != destructor ) { 283280ddee8SMarshall Clow char *ptr = static_cast <char *> (array_address); 284280ddee8SMarshall Clow size_t idx = element_count; 285280ddee8SMarshall Clow st_terminate exception_guard; 286280ddee8SMarshall Clow 287280ddee8SMarshall Clow ptr += element_count * element_size; // one past the last element 288280ddee8SMarshall Clow while ( idx-- > 0 ) { 289280ddee8SMarshall Clow ptr -= element_size; 290280ddee8SMarshall Clow destructor ( ptr ); 291280ddee8SMarshall Clow } 292280ddee8SMarshall Clow exception_guard.release (); // We're done! 293280ddee8SMarshall Clow } 294280ddee8SMarshall Clow } 295280ddee8SMarshall Clow 296280ddee8SMarshall Clow 297280ddee8SMarshall Clow // If the array_address is NULL, return immediately. Otherwise, given the 298280ddee8SMarshall Clow // (data) address of an array, the non-negative size of prefix padding for 299280ddee8SMarshall Clow // the cookie, and the size of its elements, call the given destructor on 300280ddee8SMarshall Clow // each element, using the cookie to determine the number of elements, and 301280ddee8SMarshall Clow // then delete the space by calling ::operator delete[](void *). If the 302280ddee8SMarshall Clow // destructor throws an exception, rethrow after (a) destroying the 303280ddee8SMarshall Clow // remaining elements, and (b) deallocating the storage. If the destructor 304280ddee8SMarshall Clow // throws a second exception, call terminate(). If padding_size is 0, the 305280ddee8SMarshall Clow // destructor pointer must be NULL. If the destructor pointer is NULL, no 306280ddee8SMarshall Clow // destructor call is to be made. 307280ddee8SMarshall Clow // 308280ddee8SMarshall Clow // The intent of this function is to permit an implementation to call this 309280ddee8SMarshall Clow // function when confronted with an expression of the form delete[] p in 310280ddee8SMarshall Clow // the source code, provided that the default deallocation function can be 311280ddee8SMarshall Clow // used. Therefore, the semantics of this function are consistent with 312280ddee8SMarshall Clow // those required by the standard. The requirement that the deallocation 313280ddee8SMarshall Clow // function be called even if the destructor throws an exception derives 314280ddee8SMarshall Clow // from the resolution to DR 353 to the C++ standard, which was adopted in 315280ddee8SMarshall Clow // April, 2003. 31612315edfSSaleem Abdulrasool _LIBCXXABI_FUNC_VIS void __cxa_vec_delete(void *array_address, 31712315edfSSaleem Abdulrasool size_t element_size, 31812315edfSSaleem Abdulrasool size_t padding_size, 31912315edfSSaleem Abdulrasool void (*destructor)(void *)) { 320280ddee8SMarshall Clow __cxa_vec_delete2 ( array_address, element_size, padding_size, 321280ddee8SMarshall Clow destructor, &::operator delete [] ); 322280ddee8SMarshall Clow } 323280ddee8SMarshall Clow 324280ddee8SMarshall Clow // Same as __cxa_vec_delete, except that the given function is used for 325280ddee8SMarshall Clow // deallocation instead of the default delete function. If dealloc throws 326280ddee8SMarshall Clow // an exception, the result is undefined. The dealloc pointer may not be 327280ddee8SMarshall Clow // NULL. 32812315edfSSaleem Abdulrasool _LIBCXXABI_FUNC_VIS void 32912315edfSSaleem Abdulrasool __cxa_vec_delete2(void *array_address, size_t element_size, size_t padding_size, 33012315edfSSaleem Abdulrasool void (*destructor)(void *), void (*dealloc)(void *)) { 331280ddee8SMarshall Clow if ( NULL != array_address ) { 332280ddee8SMarshall Clow char *vec_base = static_cast <char *> (array_address); 333280ddee8SMarshall Clow char *heap_block = vec_base - padding_size; 334280ddee8SMarshall Clow st_heap_block2 heap ( dealloc, heap_block ); 335280ddee8SMarshall Clow 336280ddee8SMarshall Clow if ( 0 != padding_size && NULL != destructor ) // call the destructors 337280ddee8SMarshall Clow __cxa_vec_dtor ( array_address, __get_element_count ( vec_base ), 338280ddee8SMarshall Clow element_size, destructor ); 339280ddee8SMarshall Clow } 340280ddee8SMarshall Clow } 341280ddee8SMarshall Clow 342280ddee8SMarshall Clow 343280ddee8SMarshall Clow // Same as __cxa_vec_delete, except that the given function is used for 344280ddee8SMarshall Clow // deallocation instead of the default delete function. The deallocation 345280ddee8SMarshall Clow // function takes both the object address and its size. If dealloc throws 346280ddee8SMarshall Clow // an exception, the result is undefined. The dealloc pointer may not be 347280ddee8SMarshall Clow // NULL. 34812315edfSSaleem Abdulrasool _LIBCXXABI_FUNC_VIS void 34912315edfSSaleem Abdulrasool __cxa_vec_delete3(void *array_address, size_t element_size, size_t padding_size, 35012315edfSSaleem Abdulrasool void (*destructor)(void *), void (*dealloc)(void *, size_t)) { 351280ddee8SMarshall Clow if ( NULL != array_address ) { 352280ddee8SMarshall Clow char *vec_base = static_cast <char *> (array_address); 353280ddee8SMarshall Clow char *heap_block = vec_base - padding_size; 354280ddee8SMarshall Clow const size_t element_count = padding_size ? __get_element_count ( vec_base ) : 0; 355280ddee8SMarshall Clow const size_t heap_block_size = element_size * element_count + padding_size; 356280ddee8SMarshall Clow st_heap_block3 heap ( dealloc, heap_block, heap_block_size ); 357280ddee8SMarshall Clow 358280ddee8SMarshall Clow if ( 0 != padding_size && NULL != destructor ) // call the destructors 359280ddee8SMarshall Clow __cxa_vec_dtor ( array_address, element_count, element_size, destructor ); 360280ddee8SMarshall Clow } 361280ddee8SMarshall Clow } 362280ddee8SMarshall Clow 363280ddee8SMarshall Clow 364280ddee8SMarshall Clow } // extern "C" 365280ddee8SMarshall Clow 366280ddee8SMarshall Clow } // abi 367