/*
 * This file is part of libdyn.a, the C Dynamic Object library.  It
 * contains the source code for the constructors and destructors.
 *
 * There are no restrictions on this code; however, if you make any
 * changes, I request that you document them so that I do not get
 * credit or blame for your modifications.
 *
 * Written by Barr3y Jaspan, Student Information Processing Board (SIPB)
 * and MIT-Project Athena, 1989.
 */

#include "DynObject.h"

DynObject::DynObject(int el_size_a, int inc_a)
{
     array = (DynPtr) malloc(0);
     el_size = el_size_a;
     num_el = size = debug = paranoid = 0;
     inc = inc_a;
}

DynObject::DynObject(const DynObject& obj)
{
     array = (DynPtr) malloc(obj.size * obj.el_size);
     bcopy((char *) obj.array, (char *) array, obj.size * obj.el_size);
     el_size = obj.el_size;
     num_el = obj.num_el;
     size = obj.size;
     debug = obj.debug;
     paranoid = obj.paranoid;
     inc = obj.inc;
}

DynObject& DynObject::operator=(const DynObject& obj)
{
     free(array);
     array = (DynPtr) malloc(obj.size * obj.el_size);
     bcopy((char *) obj.array, (char *) array, obj.size * obj.el_size);
     el_size = obj.el_size;
     num_el = obj.num_el;
     size = obj.size;
     debug = obj.debug;
     paranoid = obj.paranoid;
     inc = obj.inc;
}     

DynObject::~DynObject()
{
     free(array);
}
