Browse Source

indent fixes

master
despair 2 years ago
parent
commit
711569f117
6 changed files with 181 additions and 181 deletions
  1. 32
    32
      src/CFGFileParser.cpp
  2. 21
    21
      src/CFGFileParser.h
  3. 2
    2
      src/main.cpp
  4. 1
    1
      src/networking/HTTPSRequest.h
  5. 13
    13
      src/tlsf-winnt.h
  6. 112
    112
      src/tlsf.c

+ 32
- 32
src/CFGFileParser.cpp View File

@@ -4,18 +4,18 @@
#include "slre.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, "rb"); // On NT, opening in text mode translates \n into \r\n
stat(filename, cfg_fileinfo);
buffer = static_cast<char*>(tlsf_malloc(cfg_fileinfo->st_size & INT_MAX));
cfg = new BrowserConfiguration();
bytesRead = fread(buffer, sizeof(char) & INT_MAX, cfg_fileinfo->st_size & INT_MAX, cfg_file);
// Open the config file, get its size,
// allocate the buffer, read it into
// the buffer, close the file
cfg_file = fopen(filename, "rb"); // On NT, opening in text mode translates \n into \r\n
stat(filename, cfg_fileinfo);
buffer = static_cast<char*>(tlsf_malloc(cfg_fileinfo->st_size & INT_MAX));
cfg = new BrowserConfiguration();
bytesRead = fread(buffer, sizeof(char) & INT_MAX, cfg_fileinfo->st_size & INT_MAX, cfg_file);
if (!bytesRead) {
std::cout << "no config" << std::endl;
}
fclose(cfg_file);
fclose(cfg_file);
}

CFGFileParser::~CFGFileParser(){
@@ -32,26 +32,26 @@ CFGFileParser::~CFGFileParser(){
}

bool CFGFileParser::ParseText() {
// Initial buffer for pass 1. tmp holds the config file (fmr. buffer)
// token holds the actual token. pass1_length to keep track of memory,
// reallocate as needed.
char *tmp, *token;
// Initial buffer for pass 1. tmp holds the config file (fmr. buffer)
// token holds the actual token. pass1_length to keep track of memory,
// reallocate as needed.
char *tmp, *token;
size_t pass1_length = 0;
struct slre regex; // final validation before adding to second-pass buffer
// Second pass. All comments and .tags stripped out. Starts off at 512 bytes, increases if necessary.
// Second pass. All comments and .tags stripped out. Starts off at 512 bytes, increases if necessary.
char* directives = static_cast<char*>(tlsf_malloc(512));
char* tmp2;
token = strtok_r(buffer, "\n", &tmp);
while (tmp != nullptr) {
if (token[0] == '#' || token[0] == '.' || token[0] == '\n'){ // Comment, Perl directive, or single <LF> found, skip over
token = strtok_r(nullptr, "\n", &tmp);
token = strtok_r(buffer, "\n", &tmp);
while (tmp != nullptr) {
if (token[0] == '#' || token[0] == '.' || token[0] == '\n'){ // Comment, Perl directive, or single <LF> found, skip over
token = strtok_r(nullptr, "\n", &tmp);
}
else if (!isalpha(token[0])){ // The leading character is NOT a #, ., <LF>, or a letter. NB: Leading numbers are also invalid.
printf("ERROR: Config file is invalid\n");
printf("%s\n",token);
return false;
}
else {
else {
if (!slre_compile(&regex, "([A-Z0-9_]*)(:)(\\[.*\\])")){
printf("Internal error.\n");
return false;
@@ -61,20 +61,20 @@ bool CFGFileParser::ParseText() {
return false;
}
// Config directive found, add to second-pass buffer
// once we reach the 0.5KB mark, realloc exactly enough to keep going
if (pass1_length >= 512){
tlsf_realloc(directives, pass1_length+strlen(token)+2);
}
strcat(directives, token);
strcat(directives, "\t");
pass1_length = strlen(directives);
token = strtok_r(nullptr, "\n", &tmp); // continue
}
}
// First pass complete, second pass: break up into single directives and <key, value> pairs
// once we reach the 0.5KB mark, realloc exactly enough to keep going
if (pass1_length >= 512){
tlsf_realloc(directives, pass1_length+strlen(token)+2);
}
strcat(directives, token);
strcat(directives, "\t");
pass1_length = strlen(directives);
token = strtok_r(nullptr, "\n", &tmp); // continue
}
}
// First pass complete, second pass: break up into single directives and <key, value> pairs
token = strtok_r(directives, "\t", &tmp);
ntr::fast_string key, value;
while (tmp != nullptr){
while (tmp != nullptr){
key=strtok_r(token, ":", &tmp2);
value=strtok_r(nullptr, "[]", &tmp2);
// strip ending bracket
@@ -96,5 +96,5 @@ bool CFGFileParser::ParseText() {
// Writes the fully parsed configuration to a BrowserConfiguration
// object supplied by the user.
void CFGFileParser::WriteConfig(BrowserConfiguration &config){
config.Settings = cfg->Settings;
config.Settings = cfg->Settings;
}

+ 21
- 21
src/CFGFileParser.h View File

@@ -9,38 +9,38 @@
// being processed by CFGFileParser. No longer a "trivial class"
// just select by cfg->GlobalSettings....
struct BrowserConfiguration{
ntr::stringmap Settings;
ntr::stringmap Settings;
// fast allocation!
static void* operator new(std::size_t n){
if (void *mem = tlsf_malloc(n)) {
static void* operator new(std::size_t n){
if (void *mem = tlsf_malloc(n)) {
return mem;
} throw std::bad_alloc {};
}
static void operator delete(void *p) {
tlsf_free(p);
}
void clear();
static void operator delete(void *p) {
tlsf_free(p);
}
void clear();
};

class CFGFileParser {
public:
CFGFileParser(const char* filename);
~CFGFileParser();
CFGFileParser(const char* filename);
~CFGFileParser();
bool ParseText();
void WriteConfig(BrowserConfiguration &config);
static void* operator new(std::size_t n) {
if (void *mem = tlsf_malloc(n)){
return mem;
} throw std::bad_alloc {};
void WriteConfig(BrowserConfiguration &config);
static void* operator new(std::size_t n) {
if (void *mem = tlsf_malloc(n)){
return mem;
} throw std::bad_alloc {};
}
static void operator delete(void *p) {
tlsf_free(p);
}
static void operator delete(void *p) {
tlsf_free(p);
}
private:
FILE *cfg_file;
char *buffer;
struct stat *cfg_fileinfo = reinterpret_cast<struct stat*>(tlsf_malloc(sizeof(struct stat)));
FILE *cfg_file;
char *buffer;
struct stat *cfg_fileinfo = reinterpret_cast<struct stat*>(tlsf_malloc(sizeof(struct stat)));
BrowserConfiguration *cfg = new BrowserConfiguration();
size_t bytesRead;
size_t bytesRead;
};
#endif // __CFGFILEPARSER_H__

+ 2
- 2
src/main.cpp View File

@@ -104,7 +104,7 @@ int main(int argc, char *argv[]) {
}
}
#ifdef _WIN32
init_heap(); // the NT port requires it. We do it at startup now, to allow 2LSF to run at any time
init_heap(); // the NT port requires it. We do it at startup now, to allow 2LSF to run at any time
#endif
#if defined(VERSION) && defined(PLATFORM)
@@ -116,7 +116,7 @@ std::cout \
<< "# # # # # # # # # # # # # # # # #####" << std::endl \
<< "# ## # # # # # # # ## # ## # # #" << std::endl \
<< "# # ###### # # # #### # # # # ###### # #" << std::endl;
std::cout << "/g/ntr - NetRunner build " << __DATE__ << ": rev-" << VERSION << " for " << PLATFORM << std::endl;
std::cout << "/g/ntr - NetRunner build " << __DATE__ << ": rev-" << VERSION << " for " << PLATFORM << std::endl;
#else
std::cout \
<< "# # ######" << std::endl \

+ 1
- 1
src/networking/HTTPSRequest.h View File

@@ -26,7 +26,7 @@ public:
bool sendRequest(std::function<void(const HTTPResponse&)> responseCallback, std::unique_ptr<std::string> ptrPostBody) const;
const std::string versionToString(const Version version) const;
const std::string methodToString(const Method method) const;
bool initTLS();
bool initTLS();
// has to be public, otherwise how are we going to change it
Method method;
Version version;

+ 13
- 13
src/tlsf-winnt.h View File

@@ -16,25 +16,25 @@ Copyright (C) 1994, 2001, 2002, 2003, 2004, 2005,
/*
* Heap related stuff.
*/
#define get_reserved_heap_size() reserved_heap_size
#define get_committed_heap_size() (get_data_end () - get_data_start ())
#define get_heap_start() get_data_start ()
#define get_heap_end() get_data_end ()
#define get_page_size() nt_sysinfo.dwPageSize
#define get_allocation_unit() nt_sysinfo.dwAllocationGranularity
#define get_processor_type() nt_sysinfo.dwProcessorType
#define get_w32_major_version() nt_major_version
#define get_w32_minor_version() nt_minor_version
#define get_reserved_heap_size() reserved_heap_size
#define get_committed_heap_size() (get_data_end () - get_data_start ())
#define get_heap_start() get_data_start ()
#define get_heap_end() get_data_end ()
#define get_page_size() nt_sysinfo.dwPageSize
#define get_allocation_unit() nt_sysinfo.dwAllocationGranularity
#define get_processor_type() nt_sysinfo.dwProcessorType
#define get_w32_major_version() nt_major_version
#define get_w32_minor_version() nt_minor_version

extern unsigned char *get_data_start();
extern unsigned char *get_data_end();
extern unsigned long reserved_heap_size;
extern SYSTEM_INFO nt_sysinfo;
extern OSVERSIONINFO nt_apilevel;
extern BOOL using_dynamic_heap;
extern int nt_major_version;
extern int nt_minor_version;
extern int nt_build_number;
extern BOOL using_dynamic_heap;
extern int nt_major_version;
extern int nt_minor_version;
extern int nt_build_number;

enum {
OS_WIN95 = 1, // cus someone demanded Win32s support, arrrgh (yes, this is a C99 compliant comment)

+ 112
- 112
src/tlsf.c View File

@@ -64,19 +64,19 @@ extern "C" {
#include <string.h>

#ifndef TLSF_USE_LOCKS
#define TLSF_USE_LOCKS (0)
#define TLSF_USE_LOCKS (0)
#endif

#ifndef TLSF_STATISTIC
#define TLSF_STATISTIC (0)
#define TLSF_STATISTIC (0)
#endif

#ifndef USE_MMAP
#define USE_MMAP (0)
#define USE_MMAP (0)
#endif

#ifndef USE_SBRK
#define USE_SBRK (0)
#define USE_SBRK (0)
#endif


@@ -90,18 +90,18 @@ extern "C" {
#endif

#if TLSF_STATISTIC
#define TLSF_ADD_SIZE(tlsf, b) do { \
tlsf->used_size += (b->size & BLOCK_SIZE) + BHDR_OVERHEAD; \
if (tlsf->used_size > tlsf->max_size) \
tlsf->max_size = tlsf->used_size; \
} while(0)
#define TLSF_REMOVE_SIZE(tlsf, b) do { \
tlsf->used_size -= (b->size & BLOCK_SIZE) + BHDR_OVERHEAD; \
} while(0)
#define TLSF_ADD_SIZE(tlsf, b) do { \
tlsf->used_size += (b->size & BLOCK_SIZE) + BHDR_OVERHEAD; \
if (tlsf->used_size > tlsf->max_size) \
tlsf->max_size = tlsf->used_size; \
} while(0)
#define TLSF_REMOVE_SIZE(tlsf, b) do { \
tlsf->used_size -= (b->size & BLOCK_SIZE) + BHDR_OVERHEAD; \
} while(0)
#else
#define TLSF_ADD_SIZE(tlsf, b) do{}while(0)
#define TLSF_REMOVE_SIZE(tlsf, b) do{}while(0)
#define TLSF_ADD_SIZE(tlsf, b) do{}while(0)
#define TLSF_REMOVE_SIZE(tlsf, b) do{}while(0)
#endif

#ifndef _WIN32
@@ -162,11 +162,11 @@ cache_system_info (void)
union
{
struct info
{
char major;
char minor;
short platform;
} info;
{
char major;
char minor;
short platform;
} info;
DWORD data;
} version;

@@ -200,7 +200,7 @@ cache_system_info (void)
// MSYS2/Cygnus targets.
int getpagesize()
{
return nt_sysinfo.dwPageSize;
return nt_sysinfo.dwPageSize;
}
#endif
/* Info for managing our preload heap, which is essentially a fixed size
@@ -236,8 +236,8 @@ allocate_heap (void)
simply set the sbrk pointer to the base of the new heap region. */
unsigned long base =
ROUND_UP ((RVA_TO_PTR (preload_heap_section->VirtualAddress)
+ preload_heap_section->Misc.VirtualSize),
get_allocation_unit ());
+ preload_heap_section->Misc.VirtualSize),
get_allocation_unit ());
unsigned long end = 1 << VALBITS; /* 512MB */
void *ptr = NULL;

@@ -245,9 +245,9 @@ allocate_heap (void)
{
reserved_heap_size = end - base;
ptr = VirtualAlloc ((void *) base,
get_reserved_heap_size (),
MEM_RESERVE,
PAGE_NOACCESS);
get_reserved_heap_size (),
MEM_RESERVE,
PAGE_NOACCESS);
base += 0x00100000; /* 1MB increment */
}

@@ -273,22 +273,22 @@ sbrk (unsigned long increment)

/* Sanity checks. */
if ((data_region_end - size) < data_region_base)
return NULL;
return NULL;

/* We can only decommit full pages, so allow for
partial deallocation [cga]. */
partial deallocation [cga]. */
new_data_region_end = (data_region_end - size);
new_data_region_end = (unsigned char *)
((long) (new_data_region_end + syspage_mask) & ~syspage_mask);
((long) (new_data_region_end + syspage_mask) & ~syspage_mask);
new_size = real_data_region_end - new_data_region_end;
real_data_region_end = new_data_region_end;
if (new_size > 0)
{
/* Decommit size bytes from the end of the heap. */
if (using_dynamic_heap
&& !VirtualFree (real_data_region_end, new_size, MEM_DECOMMIT))
return NULL;
}
{
/* Decommit size bytes from the end of the heap. */
if (using_dynamic_heap
&& !VirtualFree (real_data_region_end, new_size, MEM_DECOMMIT))
return NULL;
}

data_region_end -= size;
}
@@ -297,20 +297,20 @@ sbrk (unsigned long increment)
{
/* Sanity checks. */
if ((data_region_end + size) >
(data_region_base + get_reserved_heap_size ()))
return NULL;
(data_region_base + get_reserved_heap_size ()))
return NULL;

/* Commit more of our heap. */
if (using_dynamic_heap
&& VirtualAlloc (data_region_end, size, MEM_COMMIT,
PAGE_READWRITE) == NULL)
return NULL;
&& VirtualAlloc (data_region_end, size, MEM_COMMIT,
PAGE_READWRITE) == NULL)
return NULL;
data_region_end += size;

/* We really only commit full pages, so record where
the real end of committed memory is [cga]. */
the real end of committed memory is [cga]. */
real_data_region_end = (unsigned char *)
((long) (data_region_end + syspage_mask) & ~syspage_mask);
((long) (data_region_end + syspage_mask) & ~syspage_mask);
}
return result;
@@ -326,15 +326,15 @@ init_heap ()

dos_header = (PIMAGE_DOS_HEADER) RVA_TO_PTR (0);
nt_header = (PIMAGE_NT_HEADERS) (((unsigned long) dos_header) +
dos_header->e_lfanew);
dos_header->e_lfanew);
/* this isn't emacs, try allocating from the app stub */
preload_heap_section = 0x400000; /* should change to 64K instead */
data_region_base = allocate_heap ();
if (!data_region_base)
{
PRINT_MSG("Error: Could not reserve dynamic heap area.\n");
exit (1);
}
{
PRINT_MSG("Error: Could not reserve dynamic heap area.\n");
exit (1);
}
data_region_end = data_region_base;
real_data_region_end = data_region_end;
@@ -366,37 +366,37 @@ round_heap (unsigned long align)
/* Unlike the preview TLSF versions, now they are statics */
#define BLOCK_ALIGN (sizeof(void *) * 2)

#define MAX_FLI (30)
#define MAX_LOG2_SLI (5)
#define MAX_SLI (1 << MAX_LOG2_SLI) /* MAX_SLI = 2^MAX_LOG2_SLI */
#define MAX_FLI (30)
#define MAX_LOG2_SLI (5)
#define MAX_SLI (1 << MAX_LOG2_SLI) /* MAX_SLI = 2^MAX_LOG2_SLI */

#define FLI_OFFSET (6) /* tlsf structure just will manage blocks bigger */
#define FLI_OFFSET (6) /* tlsf structure just will manage blocks bigger */
/* than 128 bytes */
#define SMALL_BLOCK (128)
#define REAL_FLI (MAX_FLI - FLI_OFFSET)
#define MIN_BLOCK_SIZE (sizeof (free_ptr_t))
#define BHDR_OVERHEAD (sizeof (bhdr_t) - MIN_BLOCK_SIZE)
#define TLSF_SIGNATURE (0x2A59FA59)
#define SMALL_BLOCK (128)
#define REAL_FLI (MAX_FLI - FLI_OFFSET)
#define MIN_BLOCK_SIZE (sizeof (free_ptr_t))
#define BHDR_OVERHEAD (sizeof (bhdr_t) - MIN_BLOCK_SIZE)
#define TLSF_SIGNATURE (0x2A59FA59)

#define PTR_MASK (sizeof(void *) - 1)
#define BLOCK_SIZE (0xFFFFFFFF - PTR_MASK)
#define PTR_MASK (sizeof(void *) - 1)
#define BLOCK_SIZE (0xFFFFFFFF - PTR_MASK)

#define GET_NEXT_BLOCK(_addr, _r) ((bhdr_t *) ((char *) (_addr) + (_r)))
#define MEM_ALIGN ((BLOCK_ALIGN) - 1)
#define MEM_ALIGN ((BLOCK_ALIGN) - 1)
#define ROUNDUP_SIZE(_r) (((_r) + MEM_ALIGN) & ~MEM_ALIGN)
#define ROUNDDOWN_SIZE(_r) ((_r) & ~MEM_ALIGN)
#define ROUNDUP(_x, _v) ((((~(_x)) + 1) & ((_v)-1)) + (_x))

#define BLOCK_STATE (0x1)
#define PREV_STATE (0x2)
#define BLOCK_STATE (0x1)
#define PREV_STATE (0x2)

/* bit 0 of the block size */
#define FREE_BLOCK (0x1)
#define USED_BLOCK (0x0)
#define FREE_BLOCK (0x1)
#define USED_BLOCK (0x0)

/* bit 1 of the block size */
#define PREV_FREE (0x2)
#define PREV_USED (0x0)
#define PREV_FREE (0x2)
#define PREV_USED (0x0)


#define DEFAULT_AREA_SIZE (1024*10)
@@ -584,46 +584,46 @@ static __inline__ bhdr_t *FIND_SUITABLE_BLOCK(tlsf_t * _tlsf, int *_fl, int *_sl
}


#define EXTRACT_BLOCK_HDR(_b, _tlsf, _fl, _sl) do { \
_tlsf -> matrix [_fl] [_sl] = _b -> ptr.free_ptr.next; \
if (_tlsf -> matrix[_fl][_sl]) \
_tlsf -> matrix[_fl][_sl] -> ptr.free_ptr.prev = NULL; \
else { \
clear_bit (_sl, &_tlsf -> sl_bitmap [_fl]); \
if (!_tlsf -> sl_bitmap [_fl]) \
clear_bit (_fl, &_tlsf -> fl_bitmap); \
} \
_b -> ptr.free_ptr.prev = NULL; \
_b -> ptr.free_ptr.next = NULL; \
}while(0)
#define EXTRACT_BLOCK(_b, _tlsf, _fl, _sl) do { \
if (_b -> ptr.free_ptr.next) \
_b -> ptr.free_ptr.next -> ptr.free_ptr.prev = _b -> ptr.free_ptr.prev; \
if (_b -> ptr.free_ptr.prev) \
_b -> ptr.free_ptr.prev -> ptr.free_ptr.next = _b -> ptr.free_ptr.next; \
if (_tlsf -> matrix [_fl][_sl] == _b) { \
_tlsf -> matrix [_fl][_sl] = _b -> ptr.free_ptr.next; \
if (!_tlsf -> matrix [_fl][_sl]) { \
clear_bit (_sl, &_tlsf -> sl_bitmap[_fl]); \
if (!_tlsf -> sl_bitmap [_fl]) \
clear_bit (_fl, &_tlsf -> fl_bitmap); \
} \
} \
_b -> ptr.free_ptr.prev = NULL; \
_b -> ptr.free_ptr.next = NULL; \
} while(0)
#define INSERT_BLOCK(_b, _tlsf, _fl, _sl) do { \
_b -> ptr.free_ptr.prev = NULL; \
_b -> ptr.free_ptr.next = _tlsf -> matrix [_fl][_sl]; \
if (_tlsf -> matrix [_fl][_sl]) \
_tlsf -> matrix [_fl][_sl] -> ptr.free_ptr.prev = _b; \
_tlsf -> matrix [_fl][_sl] = _b; \
set_bit (_sl, &_tlsf -> sl_bitmap [_fl]); \
set_bit (_fl, &_tlsf -> fl_bitmap); \
} while(0)
#define EXTRACT_BLOCK_HDR(_b, _tlsf, _fl, _sl) do { \
_tlsf -> matrix [_fl] [_sl] = _b -> ptr.free_ptr.next; \
if (_tlsf -> matrix[_fl][_sl]) \
_tlsf -> matrix[_fl][_sl] -> ptr.free_ptr.prev = NULL; \
else { \
clear_bit (_sl, &_tlsf -> sl_bitmap [_fl]); \
if (!_tlsf -> sl_bitmap [_fl]) \
clear_bit (_fl, &_tlsf -> fl_bitmap); \
} \
_b -> ptr.free_ptr.prev = NULL; \
_b -> ptr.free_ptr.next = NULL; \
}while(0)
#define EXTRACT_BLOCK(_b, _tlsf, _fl, _sl) do { \
if (_b -> ptr.free_ptr.next) \
_b -> ptr.free_ptr.next -> ptr.free_ptr.prev = _b -> ptr.free_ptr.prev; \
if (_b -> ptr.free_ptr.prev) \
_b -> ptr.free_ptr.prev -> ptr.free_ptr.next = _b -> ptr.free_ptr.next; \
if (_tlsf -> matrix [_fl][_sl] == _b) { \
_tlsf -> matrix [_fl][_sl] = _b -> ptr.free_ptr.next; \
if (!_tlsf -> matrix [_fl][_sl]) { \
clear_bit (_sl, &_tlsf -> sl_bitmap[_fl]); \
if (!_tlsf -> sl_bitmap [_fl]) \
clear_bit (_fl, &_tlsf -> fl_bitmap); \
} \
} \
_b -> ptr.free_ptr.prev = NULL; \
_b -> ptr.free_ptr.next = NULL; \
} while(0)
#define INSERT_BLOCK(_b, _tlsf, _fl, _sl) do { \
_b -> ptr.free_ptr.prev = NULL; \
_b -> ptr.free_ptr.next = _tlsf -> matrix [_fl][_sl]; \
if (_tlsf -> matrix [_fl][_sl]) \
_tlsf -> matrix [_fl][_sl] -> ptr.free_ptr.prev = _b; \
_tlsf -> matrix [_fl][_sl] = _b; \
set_bit (_sl, &_tlsf -> sl_bitmap [_fl]); \
set_bit (_fl, &_tlsf -> fl_bitmap); \
} while(0)

#if USE_SBRK || USE_MMAP
static __inline__ void *get_new_area(size_t * size)
@@ -893,9 +893,9 @@ void *tlsf_realloc(void *ptr, size_t size)
void *ret;

#if USE_MMAP || USE_SBRK
if (!mp) {
return tlsf_malloc(size);
}
if (!mp) {
return tlsf_malloc(size);
}
#endif

TLSF_ACQUIRE_LOCK(&((tlsf_t *)mp)->lock);
@@ -1049,7 +1049,7 @@ void *realloc_ex(void *ptr, size_t new_size, void *mem_pool)
new_size = (new_size < MIN_BLOCK_SIZE) ? MIN_BLOCK_SIZE : ROUNDUP_SIZE(new_size);
tmp_size = (b->size & BLOCK_SIZE);
if (new_size <= tmp_size) {
TLSF_REMOVE_SIZE(tlsf, b);
TLSF_REMOVE_SIZE(tlsf, b);
if (next_b->size & FREE_BLOCK) {
MAPPING_INSERT(next_b->size & BLOCK_SIZE, &fl, &sl);
EXTRACT_BLOCK(next_b, tlsf, fl, sl);
@@ -1069,12 +1069,12 @@ void *realloc_ex(void *ptr, size_t new_size, void *mem_pool)
INSERT_BLOCK(tmp_b, tlsf, fl, sl);
b->size = new_size | (b->size & PREV_STATE);
}
TLSF_ADD_SIZE(tlsf, b);
TLSF_ADD_SIZE(tlsf, b);
return (void *) b->ptr.buffer;
}
if ((next_b->size & FREE_BLOCK)) {
if (new_size <= (tmp_size + (next_b->size & BLOCK_SIZE))) {
TLSF_REMOVE_SIZE(tlsf, b);
TLSF_REMOVE_SIZE(tlsf, b);
MAPPING_INSERT(next_b->size & BLOCK_SIZE, &fl, &sl);
EXTRACT_BLOCK(next_b, tlsf, fl, sl);
b->size += (next_b->size & BLOCK_SIZE) + BHDR_OVERHEAD;
@@ -1092,7 +1092,7 @@ void *realloc_ex(void *ptr, size_t new_size, void *mem_pool)
INSERT_BLOCK(tmp_b, tlsf, fl, sl);
b->size = new_size | (b->size & PREV_STATE);
}
TLSF_ADD_SIZE(tlsf, b);
TLSF_ADD_SIZE(tlsf, b);
return (void *) b->ptr.buffer;
}
}

Loading…
Cancel
Save