-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1285 from bugsnag/release-v6.16.1
Release v6.16.1
- Loading branch information
Showing
39 changed files
with
572 additions
and
331 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// | ||
// BSG_KSFile.c | ||
// Bugsnag | ||
// | ||
// Created by Nick Dowell on 12/01/2022. | ||
// Copyright © 2022 Bugsnag Inc. All rights reserved. | ||
// | ||
|
||
#include "BSG_KSFile.h" | ||
|
||
#include "BSG_KSFileUtils.h" | ||
|
||
#include <string.h> | ||
#include <sys/param.h> | ||
|
||
static inline bool bsg_write(const int fd, const char *bytes, size_t length) { | ||
return bsg_ksfuwriteBytesToFD(fd, bytes, (ssize_t)length); | ||
} | ||
|
||
void BSG_KSFileInit(BSG_KSFile *file, int fd, char *buffer, size_t length) { | ||
file->fd = fd; | ||
file->buffer = buffer; | ||
file->bufferSize = length; | ||
file->bufferUsed = 0; | ||
} | ||
|
||
bool BSG_KSFileWrite(BSG_KSFile *file, const char *data, size_t length) { | ||
const size_t bytesCopied = MIN(file->bufferSize - file->bufferUsed, length); | ||
memcpy(file->buffer + file->bufferUsed, data, bytesCopied); | ||
file->bufferUsed += bytesCopied; | ||
data += bytesCopied; | ||
length -= bytesCopied; | ||
|
||
if (file->bufferUsed == file->bufferSize) { | ||
if (!BSG_KSFileFlush(file)) { | ||
return false; | ||
} | ||
} | ||
|
||
if (!length) { | ||
return true; | ||
} | ||
|
||
if (length >= file->bufferSize) { | ||
return bsg_write(file->fd, data, length); | ||
} | ||
|
||
memcpy(file->buffer, data, length); | ||
file->bufferUsed = length; | ||
return true; | ||
} | ||
|
||
bool BSG_KSFileFlush(BSG_KSFile *file) { | ||
if (!bsg_write(file->fd, file->buffer, file->bufferUsed)) { | ||
return false; | ||
} | ||
file->bufferUsed = 0; | ||
return true; | ||
} |
Oops, something went wrong.