Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Use more generated pack functions for NGC savedata. #2579

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion toxcore/bin_pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ static size_t buf_writer(cmp_ctx_t *ctx, const void *data, size_t count)
// Buffer too small.
return 0;
}
memcpy(&bp->bytes[bp->bytes_pos], data, count);
if (data == nullptr) {
assert(count == 0);
} else {
memcpy(&bp->bytes[bp->bytes_pos], data, count);
}
}
bp->bytes_pos += count;
return count;
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
Loading