Fix memory bug.
This commit is contained in:
@@ -273,8 +273,6 @@ static inline int length_until_newline(const char *token, int n)
|
|||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
|
|
||||||
assert(n < 4095);
|
|
||||||
|
|
||||||
// Assume token[n-1] = '\0'
|
// Assume token[n-1] = '\0'
|
||||||
for (len = 0; len < n -1; len++) {
|
for (len = 0; len < n -1; len++) {
|
||||||
if (token[len] == '\n') {
|
if (token[len] == '\n') {
|
||||||
|
|||||||
@@ -214,11 +214,11 @@ const char* get_file_data(size_t *len, const char* filename)
|
|||||||
|
|
||||||
bool LoadObjAndConvert(float bmin[3], float bmax[3], const char* filename, int num_threads)
|
bool LoadObjAndConvert(float bmin[3], float bmax[3], const char* filename, int num_threads)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 1
|
||||||
std::vector<float, lt::allocator<float>> vertices;
|
std::vector<float, lt::allocator<float>> vertices;
|
||||||
std::vector<float, lt::allocator<float>> normals;
|
std::vector<float, lt::allocator<float>> normals;
|
||||||
std::vector<float, lt::allocator<float>> texcoords;
|
std::vector<float, lt::allocator<float>> texcoords;
|
||||||
std::vector<int, lt::allocator<vertex_index>> faces;
|
std::vector<vertex_index, lt::allocator<vertex_index>> faces;
|
||||||
|
|
||||||
size_t data_len = 0;
|
size_t data_len = 0;
|
||||||
const char* data = get_file_data(&data_len, filename);
|
const char* data = get_file_data(&data_len, filename);
|
||||||
@@ -529,11 +529,15 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
Init();
|
Init();
|
||||||
|
|
||||||
|
std::cout << "Initialize GLFW..." << std::endl;
|
||||||
|
|
||||||
if(!glfwInit()){
|
if(!glfwInit()){
|
||||||
std::cerr << "Failed to initialize GLFW." << std::endl;
|
std::cerr << "Failed to initialize GLFW." << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::cout << "GLFW OK." << std::endl;
|
||||||
|
|
||||||
|
|
||||||
window = glfwCreateWindow(width, height, "Obj viewer", NULL, NULL);
|
window = glfwCreateWindow(width, height, "Obj viewer", NULL, NULL);
|
||||||
if(window == NULL){
|
if(window == NULL){
|
||||||
@@ -561,6 +565,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
float bmin[3], bmax[3];
|
float bmin[3], bmax[3];
|
||||||
if (false == LoadObjAndConvert(bmin, bmax, argv[1], num_threads)) {
|
if (false == LoadObjAndConvert(bmin, bmax, argv[1], num_threads)) {
|
||||||
|
printf("failed to load & conv\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user