Hey guys,
I have a quick question, but I feel I need to explain things in a bit of detail prior to the actual question. My next project is going to be requiring the use of a memory manager of sorts, what I would like to do is to create a library that contains this manager and providing the developer with a series of "wrapper" functions (basically just providing access to the appropriate dynamic allocation functions with additional support for the memory management operations). To implement the memory manager, I was thinking of implementing a class that handled these operations and providing access to the "wrapper" functions to this class through the means of a global variable visible to only the "inside" of the library. Just for example purposes, the following is a sample of the way the inside of the library will be setup:
Code:
// appropriate includes here
MemoryManager* myMemory;
int InitManager() { myMemory=new MemoryManager(...); }
int NewMemory(...) { /* do some stuff here */ }
// etc.
I know the above example utilizes C++ in some ways, however, the question is actually in terms of access. What I'm wondering is, would the above example have problems if the library's header is included across a larger program? To be more specific, would the MemoryManager class be capable of handling operations across the entire program or would multiple instances be attempted to be created. I have yet to be able to find an example or article talking about such a technique, but I'm guessing this might actually show signs of problems when using a multithreaded application? Correct me if I'm wrong, or if there are any articles detailing this method or perhaps a better one?
Any input would be great! I guess I could implement it and see, but I would rather not have to spend the time to implement the entire library just to find that out.