summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bx/tools/bin2c/bin2c.cpp
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/bx/tools/bin2c/bin2c.cpp')
-rw-r--r--3rdparty/bx/tools/bin2c/bin2c.cpp31
1 files changed, 17 insertions, 14 deletions
diff --git a/3rdparty/bx/tools/bin2c/bin2c.cpp b/3rdparty/bx/tools/bin2c/bin2c.cpp
index d33d9204bc9..414bce62a87 100644
--- a/3rdparty/bx/tools/bin2c/bin2c.cpp
+++ b/3rdparty/bx/tools/bin2c/bin2c.cpp
@@ -7,7 +7,7 @@
#include <vector>
#include <bx/commandline.h>
-#include <bx/crtimpl.h>
+#include <bx/file.h>
#include <bx/string.h>
class Bin2cWriter : public bx::WriterI
@@ -23,7 +23,7 @@ public:
{
}
- virtual int32_t write(const void* _data, int32_t _size, bx::Error* /*_err*/ = NULL) BX_OVERRIDE
+ virtual int32_t write(const void* _data, int32_t _size, bx::Error* /*_err*/ = NULL) override
{
const char* data = (const char*)_data;
m_buffer.insert(m_buffer.end(), data, data+_size);
@@ -59,7 +59,7 @@ public:
ascii[asciiPos] = '\0';
bx::writePrintf(m_writer, "\t" HEX_DUMP_FORMAT "// %s\n", hex, ascii);
data += asciiPos;
- hexPos = 0;
+ hexPos = 0;
asciiPos = 0;
}
}
@@ -80,7 +80,6 @@ public:
}
bx::WriterI* m_writer;
- std::string m_filePath;
std::string m_name;
typedef std::vector<uint8_t> Buffer;
Buffer m_buffer;
@@ -88,18 +87,20 @@ public:
void help(const char* _error = NULL)
{
+ bx::WriterI* stdOut = bx::getStdOut();
+
if (NULL != _error)
{
- fprintf(stderr, "Error:\n%s\n\n", _error);
+ bx::writePrintf(stdOut, "Error:\n%s\n\n", _error);
}
- fprintf(stderr
+ bx::writePrintf(stdOut
, "bin2c, binary to C\n"
"Copyright 2011-2017 Branimir Karadzic. All rights reserved.\n"
"License: https://github.com/bkaradzic/bx#license-bsd-2-clause\n\n"
);
- fprintf(stderr
+ bx::writePrintf(stdOut
, "Usage: bin2c -f <in> -o <out> -n <name>\n"
"\n"
@@ -121,21 +122,21 @@ int main(int _argc, const char* _argv[])
if (cmdLine.hasArg('h', "help") )
{
help();
- return EXIT_FAILURE;
+ return bx::kExitFailure;
}
const char* filePath = cmdLine.findOption('f');
if (NULL == filePath)
{
help("Input file name must be specified.");
- return EXIT_FAILURE;
+ return bx::kExitFailure;
}
const char* outFilePath = cmdLine.findOption('o');
if (NULL == outFilePath)
{
help("Output file name must be specified.");
- return EXIT_FAILURE;
+ return bx::kExitFailure;
}
const char* name = cmdLine.findOption('n');
@@ -147,14 +148,16 @@ int main(int _argc, const char* _argv[])
void* data = NULL;
uint32_t size = 0;
- bx::CrtFileReader fr;
+ bx::FileReader fr;
if (bx::open(&fr, filePath) )
{
size = uint32_t(bx::getSize(&fr) );
- data = malloc(size);
+
+ bx::DefaultAllocator allocator;
+ data = BX_ALLOC(&allocator, size);
bx::read(&fr, data, size);
- bx::CrtFileWriter fw;
+ bx::FileWriter fw;
if (bx::open(&fw, outFilePath) )
{
Bin2cWriter writer(&fw, name);
@@ -163,7 +166,7 @@ int main(int _argc, const char* _argv[])
bx::close(&fw);
}
- free(data);
+ BX_FREE(&allocator, data);
}
return 0;