mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Use fwrite and fputs instead of multiple putc
This commit is contained in:
@@ -43,18 +43,20 @@ static std::deque<Assertion> assertions;
|
|||||||
static std::deque<FileStackNode *> fileStackNodes;
|
static std::deque<FileStackNode *> fileStackNodes;
|
||||||
|
|
||||||
// Write a long to a file (little-endian)
|
// Write a long to a file (little-endian)
|
||||||
static void putlong(uint32_t i, FILE *f) {
|
static void putlong(uint32_t n, FILE *f) {
|
||||||
putc(i, f);
|
uint8_t bytes[] = {
|
||||||
putc(i >> 8, f);
|
(uint8_t)n,
|
||||||
putc(i >> 16, f);
|
(uint8_t)(n >> 8),
|
||||||
putc(i >> 24, f);
|
(uint8_t)(n >> 16),
|
||||||
|
(uint8_t)(n >> 24),
|
||||||
|
};
|
||||||
|
fwrite(bytes, 1, sizeof(bytes), f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write a NUL-terminated string to a file
|
// Write a NUL-terminated string to a file
|
||||||
static void putstring(std::string const &s, FILE *f) {
|
static void putstring(std::string const &s, FILE *f) {
|
||||||
for (char c : s)
|
fputs(s.c_str(), f);
|
||||||
putc(c, f);
|
putc('\0', f);
|
||||||
putc(0, f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void out_RegisterNode(FileStackNode *node) {
|
void out_RegisterNode(FileStackNode *node) {
|
||||||
|
|||||||
Reference in New Issue
Block a user