You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.2 KiB

#include "CFGFileParser.h"
#include <climits>
#include <string.h>
CFGFileParser::CFGFileParser(const char* filename){
// Open the config file, get its size,
// allocate the buffer, read it into
// the buffer, close the file
cfg_file = fopen(filename, "r");
stat(filename, cfg_fileinfo);
buffer = static_cast<char*>(tlsf_calloc(cfg_fileinfo->st_size & INT_MAX, sizeof(char) & INT_MAX));
size_t bytesRead = fread(buffer, sizeof(char) & INT_MAX, cfg_fileinfo->st_size & INT_MAX, cfg_file);
fclose(cfg_file);
}
CFGFileParser::~CFGFileParser(){
// clean up!
tlsf_free(buffer);
6 years ago
}
6 years ago
namespace ntr{
size_t string_hash(const fast_string &str){
6 years ago
size_t out = 0;
// instead of tying this to i386/amd64, because someone is eventually going to
6 years ago
// port this to ARM or some RISC nonsense
6 years ago
#if UINTPTR_MAX == 0xffffffff
MurmurHash3_x86_128 ( &str, sizeof(str), 7904542L, &out );
#elif UINTPTR_MAX == 0xffffffffffffffff
MurmurHash3_x64_128 ( &str, sizeof(str), 5484754L, &out );
#else
#endif
return out;
}
bool fast_string_compare(fast_string t1, fast_string t2){
int i = strcmp(t1.c_str(), t2.c_str());
if (!i){
6 years ago
return true;
}
else{
6 years ago
return false;
}
6 years ago
}
}