#ifndef _MEMORY_
#define _MEMORY_

#include "sys/sys"
#include "ThreadsAndMutexes/mutex/mutex"

class Memory {
public:
    // Memory accessing functions
    static void *malloc(size_t sz, string const &desc = "");
    static void *realloc(void *ptr, size_t newsz, string const &desc = "");
    static void free(void *ptr);
    static void *operator new(size_t sz);
    static void operator delete(void *ptr);
    static void *operator new[](size_t sz);
    static void operator delete[](void *ptr);

    // Follow actions immediately?
    static void mem_follow(bool b);
    static bool mem_follow();

    // Dump what we have
    static void mem_display();

    // Marker in the overview
    static void mem_mark(string const &desc = "");

    // Internal storage types
    struct MemoryEntry {
	void *ptr;
	size_t sz;
	string desc;
    };
    typedef vector<MemoryEntry> MemoryLog;
private:
    static MemoryLog s_memlog;
    static bool s_follow;
};

#endif
