summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/drumkitparser.cc4
-rw-r--r--src/instrumentparser.cc11
-rw-r--r--src/midimapparser.cc5
3 files changed, 17 insertions, 3 deletions
diff --git a/src/drumkitparser.cc b/src/drumkitparser.cc
index 8746ae0..b3f3b99 100644
--- a/src/drumkitparser.cc
+++ b/src/drumkitparser.cc
@@ -242,5 +242,9 @@ int DrumKitParser::readData(std::string& data, std::size_t size)
return -1;
}
+ data.resize(size);
+ auto nr_of_bytes_read = fread((void*)data.data(), 1, size, fd);
+ data.resize(nr_of_bytes_read);
+ return nr_of_bytes_read;
return fread((char*)data.c_str(), 1, size, fd);
}
diff --git a/src/instrumentparser.cc b/src/instrumentparser.cc
index 3ebc585..eed179d 100644
--- a/src/instrumentparser.cc
+++ b/src/instrumentparser.cc
@@ -236,6 +236,13 @@ void InstrumentParser::endTag(const std::string& name)
int InstrumentParser::readData(std::string& data, std::size_t size)
{
- if(!fd) return -1;
- return fread((char*)data.c_str(), 1, size, fd);
+ if(!fd)
+ {
+ return -1;
+ }
+
+ data.resize(size);
+ auto nr_of_bytes_read = fread((void*)data.data(), 1, size, fd);
+ data.resize(nr_of_bytes_read);
+ return nr_of_bytes_read;
}
diff --git a/src/midimapparser.cc b/src/midimapparser.cc
index 3c0e82b..2d4563a 100644
--- a/src/midimapparser.cc
+++ b/src/midimapparser.cc
@@ -57,5 +57,8 @@ int MidiMapParser::readData(std::string& data, std::size_t size)
return -1;
}
- return fread((char*)data.c_str(), 1, size, fd);
+ data.resize(size);
+ auto nr_of_bytes_read = fread((void*)data.data(), 1, size, fd);
+ data.resize(nr_of_bytes_read);
+ return nr_of_bytes_read;
}