Skip to content

Commit 573dbb9

Browse files
author
Carlos Rojas
committed
read big endian
1 parent 32acdd7 commit 573dbb9

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

src/Utils/util.cpp

+23
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,26 @@ double wa_fmin(double a, double b) {
161161
}
162162
return c;
163163
}
164+
165+
166+
//WOOD
167+
uint32_t read_B32(uint8_t **bytes) {
168+
uint8_t *b = *bytes;
169+
uint32_t n = (b[0] << 24) + (b[1] << 16) + (b[2] << 8) + b[3];
170+
*bytes += 4;
171+
return n;
172+
}
173+
174+
uint16_t read_B16(uint8_t **bytes) {
175+
uint8_t *b = *bytes;
176+
uint32_t n = (b[0] << 8) + b[1];
177+
*bytes += 2;
178+
return n;
179+
}
180+
181+
int read_B32_signed(uint8_t **bytes) {
182+
uint8_t *b = *bytes;
183+
int n = (b[0] << 24) + (b[1] << 16) + (b[2] << 8) + b[3];
184+
*bytes += 4;
185+
return n;
186+
} // TODO replace with read_LEB_32? If keep Big endian use memcpy?

src/Utils/util.h

+5
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,9 @@ double wa_fmax(double a, double b);
6767

6868
double wa_fmin(double a, double b);
6969

70+
//WOOD
71+
uint32_t read_B32(uint8_t **bytes);
72+
uint16_t read_B16(uint8_t **bytes);
73+
int read_B32_signed(uint8_t **bytes);
74+
7075
#endif

0 commit comments

Comments
 (0)