Skip to content

Commit

Permalink
Use function to find start of bytearray data
Browse files Browse the repository at this point in the history
  • Loading branch information
phischu committed Dec 20, 2024
1 parent e1ddadc commit efa2512
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions libraries/llvm/bytearray.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,17 @@ struct Pos c_bytearray_set(const struct Pos arr, const Int index, const Byte val

// Internal Operations

struct Pos c_bytearray_construct(const uint64_t n, const uint8_t *data) {
struct Pos arr = c_bytearray_new(n);
Byte *dataPtr = arr.obj + sizeof(struct Header);
memcpy(dataPtr, data, n);
return arr;
}

uint8_t* c_bytearray_data(const struct Pos arr) {
uint8_t *data = arr.obj + sizeof(struct Header);
return data;
}

struct Pos c_bytearray_construct(const uint64_t n, const uint8_t *data) {
struct Pos arr = c_bytearray_new(n);
memcpy(c_bytearray_data(arr), data, n);
return arr;
}

// Complex Operations

struct Pos c_bytearray_from_nullterminated_string(const char *data) {
Expand Down

0 comments on commit efa2512

Please sign in to comment.