From 02e25000e1375db47a5508da3adb52942090b18c Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sun, 5 Jun 2016 19:28:56 -0500 Subject: [PATCH] Removed stdlib dependency. --- src/filestore.cpp | 8 +++----- src/filestore.hpp | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/filestore.cpp b/src/filestore.cpp index d5f532a08..40677efa0 100644 --- a/src/filestore.cpp +++ b/src/filestore.cpp @@ -5,7 +5,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include #include "_memops.hpp" #include "filestore.hpp" @@ -15,7 +14,7 @@ namespace fs { uint32_t FileStore::version = 0; uint8_t *initFs(uint8_t *buffer, size_t size, bool hasDirectories) { - auto fs = (MemFsHeader*) (buffer ? buffer : malloc(size)); + auto fs = (MemFsHeader*) buffer; fs->version = FileStore::version; return (uint8_t*) fs; } @@ -65,13 +64,12 @@ void FileStore::write(RecordId id, uint8_t *data, MemFsPtr dataLen) { insert(m_root, rec); } -int FileStore::read(RecordId id, uint8_t **data, MemFsPtr *size) { +int FileStore::read(RecordId id, uint8_t *data, MemFsPtr *size) { auto rec = getRecord(m_root, id); int retval = 1; if (rec) { *size = rec->dataLen; - *data = (uint8_t*) malloc(*size); - memcpy(*data, ptr(rec->m_data), *size); + memcpy(data, ptr(rec->m_data), *size); retval = 0; } return retval; diff --git a/src/filestore.hpp b/src/filestore.hpp index 20bd43bf5..b99bcbfe5 100644 --- a/src/filestore.hpp +++ b/src/filestore.hpp @@ -85,7 +85,7 @@ class FileStore { * @param size pointer to a value that will be assigned the size of data * @return 0 if read is a success */ - int read(RecordId id, uint8_t **data, MemFsPtr *size); + int read(RecordId id, uint8_t *data, MemFsPtr *size); private: /**