Cleaned up include guards
This commit is contained in:
parent
cdca49354a
commit
c9e2bc2278
7 changed files with 16 additions and 48 deletions
|
|
@ -7,9 +7,9 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
// #define DEBUG
|
||||
// #define WRAPPER_DEBUG
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef WRAPPER_DEBUG
|
||||
typedef struct cheap
|
||||
{
|
||||
void *obj;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <ctime>
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
#include <time.h>
|
||||
|
||||
#include "chunk.hpp"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#include <assert.h>
|
||||
#include <iostream>
|
||||
#include <setjmp.h>
|
||||
#include <stdlib.h>
|
||||
#include <vector>
|
||||
|
||||
|
|
@ -11,7 +8,7 @@
|
|||
|
||||
#define HEAP_SIZE 2097152 //65536
|
||||
#define FREE_THRESH (uint) 100000
|
||||
#define DEBUG
|
||||
// #define HEAP_DEBUG
|
||||
|
||||
namespace GC
|
||||
{
|
||||
|
|
@ -89,7 +86,7 @@ namespace GC
|
|||
Heap(Heap const&) = delete;
|
||||
Heap& operator=(Heap const&) = delete;
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef HEAP_DEBUG
|
||||
void collect(CollectOption flags); // conditional collection
|
||||
void check_init(); // print dummy things
|
||||
void print_contents(); // print dummy things
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include "chunk.hpp"
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
|
||||
#include "heap.hpp"
|
||||
#include "cheap.h"
|
||||
|
||||
#ifndef DEBUG
|
||||
#ifndef WRAPPER_DEBUG
|
||||
struct cheap
|
||||
{
|
||||
void *obj;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,3 @@
|
|||
// #include <chrono>
|
||||
// #include <iostream>
|
||||
// #include <list>
|
||||
|
||||
#include "chunk.hpp"
|
||||
#include "event.hpp"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,4 @@
|
|||
#include <algorithm>
|
||||
#include <assert.h>
|
||||
#include <cstring>
|
||||
#include <execinfo.h>
|
||||
#include <iostream>
|
||||
#include <setjmp.h>
|
||||
#include <stdexcept>
|
||||
#include <stdlib.h>
|
||||
#include <vector>
|
||||
|
|
@ -83,7 +78,8 @@ namespace GC
|
|||
{
|
||||
heap.collect();
|
||||
// If memory is not enough after collect, crash with OOM error
|
||||
throw std::runtime_error(std::string("Error: Heap out of memory"));
|
||||
if (heap.m_size + size > HEAP_SIZE)
|
||||
throw std::runtime_error(std::string("Error: Heap out of memory"));
|
||||
}
|
||||
|
||||
// If a chunk was recycled, return the old chunk address
|
||||
|
|
@ -159,25 +155,6 @@ namespace GC
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Advances an iterator and returns an element
|
||||
* at position `n`.
|
||||
*
|
||||
* @param list The list to retrieve an element from.
|
||||
*
|
||||
* @param n The position to retrieve an element at.
|
||||
*
|
||||
* @returns The pointer to the chunk at position n in list.
|
||||
*/
|
||||
// Chunk *Heap::get_at(std::vector<Chunk *> &list, size_t n)
|
||||
// {
|
||||
// auto iter = list.begin();
|
||||
// if (!n)
|
||||
// return *iter;
|
||||
// std::advance(iter, n);
|
||||
// return *iter;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Returns a bool whether the profiler is enabled
|
||||
* or not.
|
||||
|
|
@ -414,7 +391,13 @@ namespace GC
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
void Heap::set_profiler(bool mode)
|
||||
{
|
||||
Heap &heap = Heap::the();
|
||||
heap.m_profiler_enable = mode;
|
||||
}
|
||||
|
||||
#ifdef HEAP_DEBUG
|
||||
/**
|
||||
* Prints the result of Heap::init() and a dummy value
|
||||
* for the current stack frame for reference.
|
||||
|
|
@ -565,12 +548,6 @@ namespace GC
|
|||
}
|
||||
}
|
||||
|
||||
void Heap::set_profiler(bool mode)
|
||||
{
|
||||
Heap &heap = Heap::the();
|
||||
heap.m_profiler_enable = mode;
|
||||
}
|
||||
|
||||
void Heap::print_allocated_chunks(Heap *heap) {
|
||||
cout << "--- Allocated Chunks ---\n" << endl;
|
||||
for (auto chunk : heap->m_allocated_chunks) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue