Browse Source

fixes

master
despair 5 years ago
parent
commit
37bd33fd9b
  1. 6
      src/app.cpp
  2. 1
      src/app.h
  3. 15
      src/glob.c
  4. 6
      src/globfree.c
  5. 5
      src/interfaces/graphical/renderers/glfw/ShaderLoader.cpp
  6. 2
      src/interfaces/graphical/renderers/glfw/opengl.cpp
  7. 3
      src/parsers/images/tga/tga.cpp

6
src/app.cpp

@ -12,7 +12,11 @@ @@ -12,7 +12,11 @@
#include "interfaces/components/ButtonComponent.h"
#include <fstream>
#ifndef _WIN32
#include <glob.h>
#else
#include <cl/glob.h>
#endif
// why can't I const this?
std::unique_ptr<Scheduler> scheduler = std::make_unique<Scheduler>();
@ -308,7 +312,7 @@ void App::transferTheme(std::string filename) { @@ -308,7 +312,7 @@ void App::transferTheme(std::string filename) {
void App::NextTheme() {
glob_t glob_result;
static unsigned int t = 0;
glob("*.ntrml", GLOB_TILDE, NULL, &glob_result);
glob("*.ntrml", GLOB_TILDE, nullptr, &glob_result);
t++;
if (t == glob_result.gl_pathc) t = 0;
/*

1
src/app.h

@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
//#include <GLFW/glfw3.h>
//#include <memory>
#include <vector>
#include "tlsf.h"
//#include <algorithm>
void doOnClick(std::string type, Component *component, Window *win);

15
src/glob.c

@ -12,13 +12,14 @@ @@ -12,13 +12,14 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <malloc.h>
#include <io.h>
#include <ctype.h>
#ifndef TVComp_MSC
#include <dir.h>
#endif
#include "tlsf.h"
#define Uses_glob
#define Uses_unistd
#define Uses_fnmatch
@ -62,13 +63,13 @@ add(const char *path) @@ -62,13 +63,13 @@ add(const char *path)
for (sp=save_list; sp; sp=sp->prev)
if (stricmp(sp->entry, path) == 0)
return 0;
sp = (Save *)malloc(sizeof(Save));
sp = (Save *)tlsf_malloc(sizeof(Save));
if (sp == 0)
return 1;
sp->entry = (char *)malloc(strlen(path)+1);
sp->entry = (char *)tlsf_malloc(strlen(path)+1);
if (sp->entry == 0)
{
free(sp);
tlsf_free(sp);
return 1;
}
/* printf("add: `%s'\n", path); */
@ -391,14 +392,14 @@ glob(const char *_pattern, int _flags, int (*_errfunc)(const char *_epath, int _ @@ -391,14 +392,14 @@ glob(const char *_pattern, int _flags, int (*_errfunc)(const char *_epath, int _
if (flags & GLOB_APPEND)
{
_pglob->gl_pathv = (char **)realloc(_pglob->gl_pathv, (l_ofs + _pglob->gl_pathc + save_count + 1) * sizeof(char *));
_pglob->gl_pathv = (char **)tlsf_realloc(_pglob->gl_pathv, (l_ofs + _pglob->gl_pathc + save_count + 1) * sizeof(char *));
if (_pglob->gl_pathv == 0)
return GLOB_NOSPACE;
l_ptr = l_ofs + _pglob->gl_pathc;
}
else
{
_pglob->gl_pathv = (char* *)malloc((l_ofs + save_count + 1) * sizeof(char *));
_pglob->gl_pathv = (char* *)tlsf_malloc((l_ofs + save_count + 1) * sizeof(char *));
if (_pglob->gl_pathv == 0)
return GLOB_NOSPACE;
l_ptr = l_ofs;
@ -414,7 +415,7 @@ glob(const char *_pattern, int _flags, int (*_errfunc)(const char *_epath, int _ @@ -414,7 +415,7 @@ glob(const char *_pattern, int _flags, int (*_errfunc)(const char *_epath, int _
l_ptr --;
_pglob->gl_pathv[l_ptr] = save_list->entry;
save_list = save_list->prev;
free(s);
tlsf_free(s);
}
if (!(flags & GLOB_NOSORT))
qsort(_pglob->gl_pathv + l_ptr, save_count, sizeof(char *), str_compare);

6
src/globfree.c

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <cl/needs.h>
#include "tlsf.h"
#ifdef NEEDS_GLOB
#define Uses_stdlib
#define Uses_glob
@ -14,7 +14,7 @@ void globfree(glob_t *_pglob) @@ -14,7 +14,7 @@ void globfree(glob_t *_pglob)
return;
for (i=0; i<_pglob->gl_pathc; i++)
if (_pglob->gl_pathv[i])
free(_pglob->gl_pathv[i]);
free(_pglob->gl_pathv);
tlsf_free(_pglob->gl_pathv[i]);
tlsf_free(_pglob->gl_pathv);
}
#endif // NEEDS_GLOB

5
src/interfaces/graphical/renderers/glfw/ShaderLoader.cpp

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
#include "Shader.h"
#include "../../../../Log.h"
#include "../../../../tlsf.h"
#include "../../../../environment/Environment.h"
#include "../../../../environment/Path.h"
@ -28,13 +29,13 @@ GLuint ShaderLoader::loadShader(const std::string &shaderName, Shader::Type type @@ -28,13 +29,13 @@ GLuint ShaderLoader::loadShader(const std::string &shaderName, Shader::Type type
long fileSize = file.tellg();
file.seekg(std::ifstream::beg);
char *buffer = static_cast<char *>(malloc(static_cast<unsigned int>(fileSize) + 1));
char *buffer = static_cast<char *>(tlsf_malloc(static_cast<unsigned int>(fileSize) + 1));
file.read(buffer, fileSize);
buffer[fileSize] = 0;
glShaderSource(shader, 1, &buffer, nullptr);
glCompileShader(shader);
free(buffer);
tlsf_free(buffer);
if(checkShader(shader, shaderName, type))
return 0;

2
src/interfaces/graphical/renderers/glfw/opengl.cpp

@ -311,7 +311,7 @@ OpenGLTexture* OpenGLWindowHandle::createSprite(unsigned char* texture, GLsizei @@ -311,7 +311,7 @@ OpenGLTexture* OpenGLWindowHandle::createSprite(unsigned char* texture, GLsizei
// FIXME: need to dynamically allocate for c++
//unsigned char data[16384][16384][4];
//unsigned char ***image = allocate_dynamic_bitmap(poth, potw, 4);
unsigned char *data = reinterpret_cast<unsigned char *>(malloc(sizeof(unsigned char) * poth * potw * 4));
unsigned char *data = reinterpret_cast<unsigned char *>(tlsf_malloc(sizeof(unsigned char) * poth * potw * 4));
//memset(data, 0, poth * potw * 4);
//memset(image, 0, poth * potw * 4);
// unflip texture

3
src/parsers/images/tga/tga.cpp

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
#include <map>
#include "../../../environment/Environment.h"
#include "../../../tlsf.h"
// tga
@ -67,7 +68,7 @@ BitMapObject *LoadTGAFile(const char *filename) { @@ -67,7 +68,7 @@ BitMapObject *LoadTGAFile(const char *filename) {
imageSize = static_cast<long int>(tgaFile->width * tgaFile->height * static_cast<long unsigned int>(colorMode & 32));
// Allocate memory for the image data.
tgaFile->imageData = static_cast<unsigned char*>(malloc(sizeof(unsigned char) * static_cast<long unsigned int>(imageSize)));
tgaFile->imageData = static_cast<unsigned char*>(tlsf_malloc(sizeof(unsigned char) * static_cast<long unsigned int>(imageSize)));
// Read the image data.
res = fread(tgaFile->imageData, sizeof(unsigned char), static_cast<long unsigned int>(imageSize), filePtr);

Loading…
Cancel
Save