30#define _Class _MutableData
47#pragma mark - MutableData
59 memcpy(self->
data.
bytes + oldLength, bytes, length);
107 self->capacity = capacity;
108 if (self->capacity) {
110 self->
data.
bytes = calloc(capacity,
sizeof(uint8_t));
141 if (newCapacity > self->capacity) {
144 self->
data.
bytes = calloc(newCapacity,
sizeof(uint8_t));
153 self->capacity = newCapacity;
159#pragma mark - Class lifecycle
188 .name =
"MutableData",
189 .superclass =
_Data(),
191 .interfaceOffset = offsetof(
MutableData, interface),
192 .interfaceSize =
sizeof(MutableDataInterface),
Class * _initialize(const ClassDef *def)
Initializes the given Class.
#define alloc(type)
Allocate and initialize and instance of type.
#define super(type, obj, method,...)
static void initialize(Class *clazz)
#define do_once(once, block)
Executes the given block at most one time.
ClassDefs are passed to _initialize via an archetype to initialize a Class.
The runtime representation of a Class.
ident interface
The interface of the Class.
Condition * init(Condition *self)
Initializes this Condition.
Class * _Data(void)
The Data archetype.
DataDestructor destroy
An optional destructor that, if set, is called on dealloc.
size_t length
The length of bytes.
uint8_t * bytes
The bytes.
MutableArray * initWithCapacity(MutableArray *self, size_t capacity)
Initializes this MutableArray with the specified capacity.
Class * _MutableData(void)
The MutableData archetype.
void setLength(MutableData *self, size_t length)
Sets the length of this Data, truncating or expanding it.
MutableData * dataWithCapacity(size_t capacity)
Returns a new MutableData with the given capacity.
MutableData * initWithData(MutableData *self, const Data *data)
Initializes this Data with the contents of data.
MutableData * init(MutableData *self)
Initializes this Data with length 0.
MutableData * data(void)
Returns a new MutableData.
void appendBytes(MutableData *self, const uint8_t *bytes, size_t length)
Appends the given bytes to this Data.
void appendData(MutableData *self, const Data *data)
Appends the given data to this Data.
Object is the root Class of The Objectively Class hierarchy.
Object * copy(const Object *self)
Creates a shallow copy of this Object.