Formatting fixes.

This commit is contained in:
2022-09-07 09:39:13 +10:00
parent 380c623776
commit 86d2c1a002
3 changed files with 115 additions and 104 deletions

View File

@@ -63,7 +63,7 @@ void asserts(void) {
// binary overlay size checks
assert(sizeof(Record) == 24); // Record struct incorrect size
assert(sizeof(Group) == 24); // Group struct incorrect size
assert(sizeof((Group) { 0 }.label) == 4); // Label union in group struct incorrect size
assert(sizeof((Group) { 0 }.label) == 4); // Label union incorrect size
assert(sizeof(Field) == 6); // Field struct incorrect size
// zlib compatability
@@ -112,7 +112,8 @@ size_t espr_decompressed_size(char *data, size_t size) {
return dc_size;
}
// Adds the size of every node up, reading decompressed size from compressed records.
// Adds the size of every node up, reading decompressed size from compressed
// records.
void dc_size_cb(Node n, void *data, void **carry_out) {
(void)carry_out;
size_t *dc_size = data;
@@ -162,7 +163,8 @@ struct decom {
void espr_decompress(char *data, size_t size, char *buf, size_t buf_size) {
struct decom s = { .buf = buf, .remaining = buf_size };
struct walker_callbacks cb = { .pre = decompress_pre, .post = decompress_post, .data = &s };
struct walker_callbacks cb =
{ .pre = decompress_pre, .post = decompress_post, .data = &s };
espr_walk(data, size, cb);
}
@@ -189,7 +191,12 @@ void decompress_pre(Node n, void *decom_ptr, void **carry_out) {
uint32_t to_copy = dc_size;
uint32_t cur_size = n.header.record->size - sizeof(uint32_t);
char *data_start = n.data + sizeof(uint32_t);
int ret = uncompress((Bytef *)d->buf, (uLongf *)&to_copy, (Bytef *)data_start, (uLong)cur_size);
int ret = uncompress(
(Bytef *)d->buf,
(uLongf *)&to_copy,
(Bytef *)data_start,
(uLong)cur_size
);
assert(ret == Z_OK);
assert(to_copy == dc_size);
@@ -265,10 +272,11 @@ char *walk_concat(char *data, size_t size, struct walker_callbacks cb) {
return data;
}
/* Walk a group record. Group records are containers for any other type of record,
* including other group records.
/* Walk a group record. Group records are containers for any other type of
* record, including other group records.
*
* This function will also call `cb` with the node constructed from this group record.
* This function will also call `cb` with the node constructed from this group
* record.
*/
char *walk_group(char *data, struct walker_callbacks cb) {
Group *const header = (Group *const)data;
@@ -358,7 +366,8 @@ void print_group_label(Group *header) {
printf("%d", header->label.number);
case GT_EXTERIOR_CELL_BLOCK:
case GT_EXTERIOR_CELL_SUBBLOCK:
printf("X: %d, Y: %d", header->label.coord[1], header->label.coord[0]);
printf("X: %d, Y: %d",
header->label.coord[1], header->label.coord[0]);
case GT_WORLD_CHILDREN:
case GT_CELL_CHILDREN:
case GT_TOPIC_CHILDREN: