#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "MutableData.h"
Go to the source code of this file.
◆ _Class
◆ _MutableData()
Class * _MutableData |
( |
void |
| ) |
|
Definition at line 182 of file MutableData.c.
182 {
185
188 .name = "MutableData",
189 .superclass =
_Data(),
191 .interfaceOffset = offsetof(
MutableData, interface),
192 .interfaceSize = sizeof(MutableDataInterface),
194 });
195 });
196
197 return clazz;
198}
Class * _initialize(const ClassDef *def)
Initializes the given Class.
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.
Class * _Data(void)
The Data archetype.
◆ appendBytes()
static void appendBytes |
( |
MutableData * |
self, |
|
|
const uint8_t * |
bytes, |
|
|
size_t |
length |
|
) |
| |
|
static |
Definition at line 53 of file MutableData.c.
53 {
54
56
58
59 memcpy(self->
data.
bytes + oldLength, bytes, length);
60}
size_t length
The length of bytes.
uint8_t * bytes
The bytes.
void setLength(MutableData *self, size_t length)
Sets the length of this Data, truncating or expanding it.
◆ appendData()
Definition at line 66 of file MutableData.c.
66 {
67
69}
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.
◆ copy()
- See also
- Object::copy(const Object *)
Definition at line 37 of file MutableData.c.
37 {
38
40
43
45}
#define alloc(type)
Allocate and initialize and instance of type.
Condition * init(Condition *self)
Initializes this Condition.
Object is the root Class of The Objectively Class hierarchy.
◆ data()
◆ dataWithCapacity()
static MutableData * dataWithCapacity |
( |
size_t |
capacity | ) |
|
|
static |
Definition at line 84 of file MutableData.c.
84 {
85
87}
MutableArray * initWithCapacity(MutableArray *self, size_t capacity)
Initializes this MutableArray with the specified capacity.
◆ init()
◆ initialize()
static void initialize |
( |
Class * |
clazz | ) |
|
|
static |
- See also
- Class::initialize(Class *)
Definition at line 164 of file MutableData.c.
164 {
165
167
176}
ident interface
The interface of the Class.
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.
void appendData(MutableData *self, const Data *data)
Appends the given data to this Data.
Object * copy(const Object *self)
Creates a shallow copy of this Object.
◆ initWithCapacity()
Definition at line 102 of file MutableData.c.
102 {
103
105 if (self) {
106
107 self->capacity = capacity;
108 if (self->capacity) {
109
110 self->
data.
bytes = calloc(capacity,
sizeof(uint8_t));
112 }
113
115 }
116
117 return self;
118}
#define super(type, obj, method,...)
DataDestructor destroy
An optional destructor that, if set, is called on dealloc.
◆ initWithData()
Definition at line 124 of file MutableData.c.
124 {
125
127 if (self) {
129 }
130
131 return self;
132}
◆ setLength()
static void setLength |
( |
MutableData * |
self, |
|
|
size_t |
length |
|
) |
| |
|
static |
Definition at line 138 of file MutableData.c.
138 {
139
141 if (newCapacity > self->capacity) {
142
144 self->
data.
bytes = calloc(newCapacity,
sizeof(uint8_t));
146 } else {
149
151 }
152
153 self->capacity = newCapacity;
154 }
155
157}