Skip to content

Commit

Permalink
Implemented write functions
Browse files Browse the repository at this point in the history
  • Loading branch information
cheng-alvin committed Nov 30, 2023
1 parent 29baa84 commit 270d424
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions libjas/write.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "write.h"
#include <stdint.h>

uint8_t *write8(uint8_t *buffer, uint8_t value, int len) {
len++;
buffer = realloc(len * sizeof(uint8_t));
buffer[len - 1] = value;
return buffer;
}

uint8_t *write16(uint8_t *buffer, uint16_t value, int len) {
buffer = write8(buffer, (uint8_t)value >> 8, len);
len++;
buffer = write8(buffer, (uint8_t)value, len);
return buffer;
}

0 comments on commit 270d424

Please sign in to comment.