Go to the documentation of this file.00001
00002 #include <blort/Tracker/ShaderUtils.h>
00003 #include <stdio.h>
00004
00005 void* Tracking::malloc_align(size_t size, int align)
00006 {
00007 char *tmp = (char*)malloc(size+align-1+sizeof(void*));
00008 char *addr = tmp+align-1+sizeof(void*);
00009 addr -= (long)addr & (align-1);
00010 ((void**)addr)[-1] = tmp;
00011 return addr;
00012 }
00013
00014 void Tracking::free_align(void *addr)
00015 {
00016 void *tmp = ((void**)addr)[-1];
00017 free(tmp);
00018 }
00019
00020 char* Tracking::read_text_file(const char* file)
00021 {
00022 if(!file) return NULL;
00023
00024 FILE *f = fopen(file ,"r");
00025 if(!f) return NULL;
00026
00027 fseek(f, 0, SEEK_END);
00028 int sz = ftell(f);
00029 fseek(f, 0, SEEK_SET);
00030
00031 char *retv = (char*)malloc(sz+1);
00032 size_t size = fread(retv, sz, 1, f);
00033 retv[sz] = size;
00034 retv[sz] = 0;
00035 fclose(f);
00036
00037 return retv;
00038 }
00039
00040
blort
Author(s): Michael Zillich,
Thomas Mörwald,
Johann Prankl,
Andreas Richtsfeld,
Bence Magyar (ROS version)
autogenerated on Thu Jan 2 2014 11:38:25