Skip to content

Commit

Permalink
refactor: Use more generated pack functions for NGC savedata.
Browse files Browse the repository at this point in the history
  • Loading branch information
iphydf committed Jan 17, 2024
1 parent 255cbd0 commit 7d80276
Show file tree
Hide file tree
Showing 3 changed files with 249 additions and 83 deletions.
6 changes: 5 additions & 1 deletion toxcore/bin_pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ static size_t buf_writer(cmp_ctx_t *ctx, const void *data, size_t data_size)
// Buffer too small.
return 0;
}
memcpy(&bp->bytes[bp->bytes_pos], data, data_size);
if (data == nullptr) {
assert(data_size == 0);
} else {
memcpy(&bp->bytes[bp->bytes_pos], data, data_size);
}
}
bp->bytes_pos += data_size;
return data_size;
Expand Down
2 changes: 1 addition & 1 deletion toxcore/bin_pack.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ non_null() bool bin_pack_u64(Bin_Pack *bp, uint64_t val);
/** @brief Pack an empty array member as a MessagePack nil value. */
non_null() bool bin_pack_nil(Bin_Pack *bp);
/** @brief Pack a byte array as MessagePack bin. */
non_null() bool bin_pack_bin(Bin_Pack *bp, const uint8_t *data, uint32_t length);
non_null(1) nullable(2) bool bin_pack_bin(Bin_Pack *bp, const uint8_t *data, uint32_t length);
/** @brief Start packing a custom binary representation.
*
* A call to this function must be followed by exactly `size` bytes packed by functions below.
Expand Down
Loading

0 comments on commit 7d80276

Please sign in to comment.