Skip to content

Commit

Permalink
Write logs in the buffer first to ensure the order of log entries (#508)
Browse files Browse the repository at this point in the history
# Conflicts:
#	.swiftpm/xcode/xcshareddata/xcschemes/KSCrash-Package.xcscheme
  • Loading branch information
xuezhulian authored and GLinnik21 committed Jun 21, 2024
1 parent c9b13a7 commit fd0360b
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions Source/KSCrash/Recording/Tools/KSFileUtils.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,18 +475,17 @@ void ksfu_closeBufferedWriter(KSBufferedWriter* writer)

bool ksfu_writeBufferedWriter(KSBufferedWriter* writer, const char* restrict const data, const int length)
{
if(length > writer->bufferLength)
{
return ksfu_writeBytesToFD(writer->fd, data, length);
}
if(length > writer->bufferLength - writer->position)
{
if (!ksfu_flushBufferedWriter(writer))
{
return false;
}
}

if(length > writer->bufferLength)
{
return ksfu_writeBytesToFD(writer->fd, data, length);
}
memcpy(writer->buffer + writer->position, data, length);
writer->position += length;
return true;
Expand Down

0 comments on commit fd0360b

Please sign in to comment.