summaryrefslogtreecommitdiff
path: root/src/common.cc
diff options
context:
space:
mode:
authorBen Smith <binjimin@gmail.com>2017-03-06 11:34:37 -0800
committerGitHub <noreply@github.com>2017-03-06 11:34:37 -0800
commite4dda12b17a5323a56b6782a6787f258ed2d8c81 (patch)
treec47e34928fc9b48f5b8dd1579e4c0213074b6494 /src/common.cc
parentb6e5735f3bfbb66d76142fc2f404da796289fc76 (diff)
downloadwabt-e4dda12b17a5323a56b6782a6787f258ed2d8c81.tar.gz
wabt-e4dda12b17a5323a56b6782a6787f258ed2d8c81.tar.bz2
wabt-e4dda12b17a5323a56b6782a6787f258ed2d8c81.zip
Use new/delete instead of malloc/free (#332)
Also switch some void* -> char*, because it removes some unnecessary casts. C++ does not like void*.
Diffstat (limited to 'src/common.cc')
-rw-r--r--src/common.cc6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/common.cc b/src/common.cc
index 0af8b456..b05de5df 100644
--- a/src/common.cc
+++ b/src/common.cc
@@ -114,10 +114,10 @@ bool string_slices_are_equal(const StringSlice* a, const StringSlice* b) {
void destroy_string_slice(StringSlice* str) {
assert(str);
- wabt_free(const_cast<void*>(static_cast<const void*>(str->start)));
+ delete [] str->start;
}
-Result read_file(const char* filename, void** out_data, size_t* out_size) {
+Result read_file(const char* filename, char** out_data, size_t* out_size) {
FILE* infile = fopen(filename, "rb");
if (!infile) {
const char* format = "unable to read file %s";
@@ -143,7 +143,7 @@ Result read_file(const char* filename, void** out_data, size_t* out_size) {
return Result::Error;
}
- void* data = wabt_alloc(size);
+ char* data = new char [size];
if (size != 0 && fread(data, size, 1, infile) != 1) {
perror("fread failed");
return Result::Error;