src/core/c/pandalib.c
// Creates a new Panda Array copied from a subrange of an existing array.
// class_ptr - the specific Array class to create
// array - the array to copy from
// elementSize - size of each element
// elementsArePointers - true if the array elements are pointers (if not,
//         the garbage collector doesn't need to worry about them)
Creates a new Panda Array copied from a subrange of an existing array.
class_ptr - the specific Array class to create
array - the array to copy from
elementSize - size of each element
elementsArePointers - true if the array elements are pointers (if not,
the garbage collector doesn't need to worry about them)
Creates a new Panda Array copied from a subrange of an existing array . class_ptr - the specific Array class to create array - the array to copy from elementSize - size of each element elementsArePointers - true if the array elements are pointers ( if not the garbage collector doesn ' t need to worry about them )
PrimitiveArray* pandaNewPrimitiveArrayCopy(Class* class_ptr, 
            PrimitiveArray* array, Int elementSize, Bit elementsArePointers) {
    if (elementSize < 0)
       pandaFatalError("creating array with negative size");
    PrimitiveArray* result = (PrimitiveArray*) _pandaNew(class_ptr, 
            sizeof(PrimitiveArray));
    result->length = array->length;
    int size = result->length * elementSize;
    result->contents = pandaAlloc(size, elementsArePointers);
    memcpy(result->contents, ((Int8*) array->contents), size);
    return result;
}
PrimitiveArray * pandaNewPrimitiveArrayCopy ( Class * class_ptr , PrimitiveArray * array , Int elementSize , Bit elementsArePointers ) { if ( elementSize < 0 ) pandaFatalError ( " " ) ; PrimitiveArray * result = ( PrimitiveArray * ) _pandaNew ( class_ptr , sizeof ( PrimitiveArray ) ) ; result -> length = array -> length ; int size = result -> length * elementSize ; result -> contents = pandaAlloc ( size , elementsArePointers ) ; memcpy ( result -> contents , ( ( Int8 * ) array -> contents ) , size ) ; return result ; }
Creates a new Panda Array copied from a subrange of an existing array.
Creates a new Panda Array copied from a subrange of an existing array .