reformat the code by enabeling assignment- and declaration alignment.

This commit is contained in:
2025-10-09 12:17:04 +02:00
parent cebe0df8a2
commit d4fabf437c
12 changed files with 83 additions and 83 deletions

View File

@@ -18,10 +18,10 @@
#define CHUNKS 0x400 // amount of chunks in a file
enum mcx_compression {
MCX_COMPRESSION_GZIP = 0x01,
MCX_COMPRESSION_ZLIB = 0x02,
MCX_COMPRESSION_NONE = 0x03,
MCX_COMPRESSION_LZ4 = 0x04,
MCX_COMPRESSION_GZIP = 0x01,
MCX_COMPRESSION_ZLIB = 0x02,
MCX_COMPRESSION_NONE = 0x03,
MCX_COMPRESSION_LZ4 = 0x04,
MCX_COMPRESSION_CUSTOM = 0x7F,
};
@@ -97,7 +97,7 @@ static usize delchunk(u8 *restrict buf, u32 *restrict table, usize rmb, int sidx
blen = slen * SECTOR; // compute the byte length of the chunk
// reset the table data
table[sidx] = 0;
table[sidx] = 0;
table[sidx + CHUNKS] = htobe32(time(NULL)); // assign the current time to the timestamp, for correctness NOTE: might need to zero-out instead
// move the succeeding chunks over the deleted chunk
@@ -129,7 +129,7 @@ usize mcx_delchunk_range(u8 *restrict buf, int start, int end) {
// zeroes-out the chunk data within this range. (and set the timestamp)
u32 ts = htobe32(time(NULL));
for (int i = start; i <= end; i++) {
table[i] = 0;
table[i] = 0;
table[i + CHUNKS] = ts;
}

View File

@@ -9,9 +9,9 @@
/* contains chunk metadata */
struct mcx_chunk {
usize idx; // byte offset for start of chunk data
u32 len; // byte length of chunk (+ padding)
u32 time; // modification time in epoch seconds
usize idx; // byte offset for start of chunk data
u32 len; // byte length of chunk (+ padding)
u32 time; // modification time in epoch seconds
};
/* Deletes a single chunk (`chunk`) out of `buf`.

View File

@@ -38,10 +38,10 @@ static inline u64 buftoh64(const void *restrict buf) {
* Outputs the allocated data to `out`, returns where the next pointer would be. */
static const u8 *procarr(const u8 *restrict buf, i32 nmemb, uint size, struct nbt_array *restrict out) {
usize len = nmemb * size;
*out = (struct nbt_array){
out->nmemb = nmemb,
out->dat = malloc(len),
};
*out = (struct nbt_array){
out->nmemb = nmemb,
out->dat = malloc(len),
};
if (!out->dat)
return buf + len;
@@ -92,7 +92,7 @@ const u8 *nbt_proctag(const u8 *restrict buf, u16 slen, void *restrict out) {
const u8 *ptr, *tmp;
ptr = buf + 3 + slen;
i32 nmem;
i32 nmem;
uint size;
switch (*buf) {
@@ -152,7 +152,7 @@ static const u8 *nexttag_list(const u8 *restrict ptr, uint *restrict const dpt,
* Where the value is decremented until we reach `0`.
* - `tags` shall contain `MAX_DEPTH` of items representing the list's stored type. */
static const u8 *nexttag(const u8 *restrict tag, uint *restrict const dpt, i32 *restrict const lens, u8 *restrict const tags) {
u8 type;
u8 type;
const u8 *ptr = tag;
if (lens[*dpt]) {
type = tags[*dpt];
@@ -195,9 +195,9 @@ static const u8 *nexttag(const u8 *restrict tag, uint *restrict const dpt, i32 *
*/
const u8 *nbt_nexttag(const u8 *restrict buf) {
const u8 *tag;
u8 tags[MAX_DEPTH] = {0};
i32 lens[MAX_DEPTH] = {0};
uint dpt = 0;
u8 tags[MAX_DEPTH] = {0};
i32 lens[MAX_DEPTH] = {0};
uint dpt = 0;
tag = buf;
do {

View File

@@ -21,23 +21,23 @@
/* specifies the NBT tag IDs.
* NOTE: every type is stored as BE (big-endian) in the file. */
enum nbt_tagid {
NBT_END = 0x00, // signifies the end of a compound tag
NBT_I8 = 0x01, // next byte is for an 8 bit signed integer.
NBT_I16 = 0x02, // next 2 bytes are for a 16 bit signed integer
NBT_I32 = 0x03, // next 4 bytes are for a 32 bit signed integer
NBT_I64 = 0x04, // next 8 bytes are for a 64 bit signed integer
NBT_F32 = 0x05, // next 4 bytes are for a single-precision floating-point
NBT_F64 = 0x06, // next 8 bytes are for a double-precision floating-point
NBT_ARR_I8 = 0x07, // starts with a i32, denoting size, followed by the i8 data
NBT_STR = 0x08, // starts with a u16, denoting size, followed by the UTF-8 data
NBT_LIST = 0x09, // starts with an ID, followed by a 32 bit signed integer denoting the size
NBT_END = 0x00, // signifies the end of a compound tag
NBT_I8 = 0x01, // next byte is for an 8 bit signed integer.
NBT_I16 = 0x02, // next 2 bytes are for a 16 bit signed integer
NBT_I32 = 0x03, // next 4 bytes are for a 32 bit signed integer
NBT_I64 = 0x04, // next 8 bytes are for a 64 bit signed integer
NBT_F32 = 0x05, // next 4 bytes are for a single-precision floating-point
NBT_F64 = 0x06, // next 8 bytes are for a double-precision floating-point
NBT_ARR_I8 = 0x07, // starts with a i32, denoting size, followed by the i8 data
NBT_STR = 0x08, // starts with a u16, denoting size, followed by the UTF-8 data
NBT_LIST = 0x09, // starts with an ID, followed by a 32 bit signed integer denoting the size
NBT_COMPOUND = 0x0A, // compound tag, contains tags and is delimited by `NBT_END`
NBT_ARR_I32 = 0x0B, // starts with a i32, denoting size, followed by the i32 data
NBT_ARR_I64 = 0x0C, // starts with a i32, denoting size, followed by the u32 data
NBT_ARR_I32 = 0x0B, // starts with a i32, denoting size, followed by the i32 data
NBT_ARR_I64 = 0x0C, // starts with a i32, denoting size, followed by the u32 data
};
struct nbt_array {
i32 nmemb;
i32 nmemb;
void *dat;
};