summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib
diff options
context:
space:
mode:
author Oliver Stöneberg <firewave@users.noreply.github.com>2012-09-08 10:58:51 +0000
committer Oliver Stöneberg <firewave@users.noreply.github.com>2012-09-08 10:58:51 +0000
commitf08b72209bf1edd15f267e75a6e61ad16a87ac31 (patch)
tree92cff307a0d598f4a5a4fc731644f995de6ab38b /src/lib
parent1a391dd0442a66cc53cfed2b39fd753751e8039a (diff)
removed astring::stringbuffer() / use cached value in astring::len() instead of strlen() (no whatsnew)
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/util/astring.h3
-rw-r--r--src/lib/util/chd.c7
2 files changed, 7 insertions, 3 deletions
diff --git a/src/lib/util/astring.h b/src/lib/util/astring.h
index 50e0de97911..763537241a1 100644
--- a/src/lib/util/astring.h
+++ b/src/lib/util/astring.h
@@ -104,14 +104,13 @@ public:
// C string conversion operators and helpers
operator const char *() const { return m_text; }
const char *cstr() const { return m_text; }
- char *stringbuffer(int size) { ensure_room(size); return m_text; }
// buffer management
astring &reset() { return cpy(""); }
astring &expand(int length) { ensure_room(length); return *this; }
// length query
- int len() const { return strlen(m_text); }
+ int len() const { return m_len; }
// copy helpers
astring &cpy(const char *src, int count);
diff --git a/src/lib/util/chd.c b/src/lib/util/chd.c
index 70510531db0..406b478eb14 100644
--- a/src/lib/util/chd.c
+++ b/src/lib/util/chd.c
@@ -1079,7 +1079,12 @@ chd_error chd_file::read_metadata(chd_metadata_tag searchtag, UINT32 searchindex
throw CHDERR_METADATA_NOT_FOUND;
// read the metadata
- file_read(metaentry.offset + METADATA_HEADER_SIZE, output.stringbuffer(metaentry.length), metaentry.length);
+ // TODO: how to properly allocate a dynamic char buffer?
+ char* metabuf = new char[metaentry.length+1];
+ memset(metabuf, 0x00, metaentry.length+1);
+ file_read(metaentry.offset + METADATA_HEADER_SIZE, metabuf, metaentry.length);
+ output.cpy(metabuf);
+ delete[] metabuf;
return CHDERR_NONE;
}