Browse Source

some notes

master
despair 5 years ago
parent
commit
ec335dd123
  1. 10
      src/CFGFileParser.cpp
  2. 1
      src/CFGFileParser.h
  3. 1
      src/netrunner.h
  4. 1
      src/networking/HTTPSRequest.cpp
  5. 12
      src/tlsf.c

10
src/CFGFileParser.cpp

@ -1,3 +1,4 @@ @@ -1,3 +1,4 @@
// ©2008-2017 despair <despair@netrunner.cc>
#include "CFGFileParser.h"
#include <climits>
@ -17,8 +18,14 @@ CFGFileParser::CFGFileParser(const char* filename){ @@ -17,8 +18,14 @@ CFGFileParser::CFGFileParser(const char* filename){
}
CFGFileParser::~CFGFileParser(){
// clean up!
// clean up!
// This buffer has been written to and co-opted by
// libc itself, but it stands that we initially allocated
// it. So we'll free it ourselves.
tlsf_free(buffer);
// We've already copied the collected config directives
// into a global class, we can safely delete the scratch
// object, and its file info block.
tlsf_free(cfg_fileinfo);
delete cfg;
}
@ -65,6 +72,7 @@ void CFGFileParser::ParseText() { @@ -65,6 +72,7 @@ void CFGFileParser::ParseText() {
}
std::cout << std::endl;
#endif
// clean up, we're done parsing
tlsf_free(directives);
}

1
src/CFGFileParser.h

@ -1,3 +1,4 @@ @@ -1,3 +1,4 @@
// ©2008-2017 despair <despair@netrunner.cc>
#ifndef __CFGFILEPARSER_H__
#define __CFGFILEPARSER_H__
#include "netrunner.h"

1
src/netrunner.h

@ -1,3 +1,4 @@ @@ -1,3 +1,4 @@
// ©2008-2017 despair <despair@netrunner.cc>
#include "Murmur3.h"
#include <string>
#include <unordered_map>

1
src/networking/HTTPSRequest.cpp

@ -1,3 +1,4 @@ @@ -1,3 +1,4 @@
// ©2008-2017 despair <despair@netrunner.cc>
#include "HTTPSRequest.h"
#include <errno.h>
#include <iostream>

12
src/tlsf.c

@ -196,6 +196,8 @@ cache_system_info (void) @@ -196,6 +196,8 @@ cache_system_info (void)
}
#ifndef _WIN64
// Apparently, MinGW defined this function for MinGW in addition to
// MSYS2/Cygnus targets.
int getpagesize()
{
return nt_sysinfo.dwPageSize;
@ -313,6 +315,9 @@ sbrk (unsigned long increment) @@ -313,6 +315,9 @@ sbrk (unsigned long increment)
return result;
}
/* This function initialises the heap for use with the sbrk(3)
stub, on Windows NT. MUST call before using 2LSF!!! */
void
init_heap ()
{
@ -676,6 +681,10 @@ static char *mp = NULL; /* Default memory pool. */ @@ -676,6 +681,10 @@ static char *mp = NULL; /* Default memory pool. */
/******************************************************************/
size_t init_memory_pool(size_t mem_pool_size, void *mem_pool)
{
/* This initialises the stack-allocation mode of 2LSF, you must
declare your own fixed-size blocks beforehand, somewhere in the
data segment of your app.
*/
/******************************************************************/
tlsf_t *tlsf;
bhdr_t *b, *ib;
@ -840,7 +849,7 @@ void *tlsf_malloc(size_t size) @@ -840,7 +849,7 @@ void *tlsf_malloc(size_t size)
/******************************************************************/
void *ret;
#if USE_MMAP || USE_SBRK
#if USE_MMAP || USE_SBRK // Dynamic allocation using POSIX facilities (must port if undefined)
if (!mp) {
size_t area_size;
void *area;
@ -854,6 +863,7 @@ void *tlsf_malloc(size_t size) @@ -854,6 +863,7 @@ void *tlsf_malloc(size_t size)
}
#endif
// Dynamic allocation using stack/fixed-block pool
TLSF_ACQUIRE_LOCK(&((tlsf_t *)mp)->lock);
ret = malloc_ex(size, mp);

Loading…
Cancel
Save