From 0daac5781e93e27cf2ad4789aa6d56fc10a5edaa Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Wed, 20 Apr 2011 15:22:35 -0400 Subject: [PATCH] loadfile_t takes Buffer ref instead of ptr --- WFObj.cc | 10 +++++----- WFObj.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/WFObj.cc b/WFObj.cc index 01520af..aeab821 100644 --- a/WFObj.cc +++ b/WFObj.cc @@ -135,7 +135,7 @@ bool WFObj::load(const char *fname) m_path = fname; Buffer buff; - if (!m_loadfile(fname, &buff)) + if (!m_loadfile(fname, buff)) return false; return load(buff); @@ -330,7 +330,7 @@ WFObj::VertexRef WFObj::readVertexRef(const std::string ref) void WFObj::loadMaterial(const std::string & name) { Buffer buff; - if (!m_loadfile(name.c_str(), &buff)) + if (!m_loadfile(name.c_str(), buff)) { cerr << "WFObj: error: couldn't open material file '" << name << "'" << endl; @@ -413,7 +413,7 @@ void WFObj::loadMaterial(const std::string & name) } } -bool WFObj::loadfile(const char *path, Buffer *buff) +bool WFObj::loadfile(const char *path, Buffer & buff) { struct stat st; @@ -422,8 +422,8 @@ bool WFObj::loadfile(const char *path, Buffer *buff) int fd = open(path, O_RDONLY); if (fd > 0) { - buff->alloc(st.st_size); - int num_read = read(fd, buff->data, st.st_size); + buff.alloc(st.st_size); + int num_read = read(fd, buff.data, st.st_size); close(fd); if (num_read > 0) return true; diff --git a/WFObj.h b/WFObj.h index bb8c4a5..8cf2830 100644 --- a/WFObj.h +++ b/WFObj.h @@ -28,7 +28,7 @@ public: bool m_alloc; }; - typedef bool (*loadfile_t)(const char *fname, Buffer *buff); + typedef bool (*loadfile_t)(const char *fname, Buffer & buff); typedef GLuint (*loadtexture_t)(const char *fname); enum { VERTEX, VERTEX_TEXTURE, VERTEX_NORMAL, VERTEX_TYPES }; @@ -96,7 +96,7 @@ protected: std::vector readFaces(const std::vector & parts); VertexRef readVertexRef(const std::string ref); void updateAABB(); - static bool loadfile(const char *path, Buffer *buff); + static bool loadfile(const char *path, Buffer & buff); std::string getLine(const Buffer & buff, size_t idx, size_t *update_idx); void loadMaterial(const std::string & name);