loadfile_t takes Buffer ref instead of ptr

This commit is contained in:
Josh Holtrop 2011-04-20 15:22:35 -04:00
parent a46b5baa05
commit 0daac5781e
2 changed files with 7 additions and 7 deletions

View File

@ -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;

View File

@ -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<Face> readFaces(const std::vector<std::string> & 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);