More on vector new/delete

Mark Mitchell mark at codesourcery.com
Thu Jun 29 06:12:30 UTC 2000


I think we should also add a runtime support routine for copy
constructors.  Here's a sample definition:

  extern "C" void
  __cxa_vec_cctor (void *dest_array,
                   void *src_array,
		   size_t element_count,
		   size_t element_size,
		   void (*constructor) (void *, void *),
		   void (*destructor) (void *))
  {
    size_t ix = 0;
    char *dest_ptr = static_cast <char *> (dest_array);
    char *src_ptr = static_cast <char *> (src_array);

    try
      {
	if (constructor)
	  for (; ix != element_count; 
	       ix++, src_ptr += element_size, dest_ptr += element_size)
	    constructor (dest_ptr, src_ptr);
      }
    catch (...)
      {
	__uncatch_exception ();
	__cxa_vec_dtor (dest_array, ix, element_size, destructor);
	throw;
      }
  }

This routine will be useful to compilers when copying a structure
containing an array.  The EDG front-end uses this method.

Jim, I'm sorry to keep adding things to your list of issues...

--
Mark Mitchell                   mark at codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com




More information about the cxx-abi-dev mailing list