1

I want to create a transparent user level library that changes what malloc() does. I want to have my own implementation of malloc but I don't want any change in the source code. The code has to be linked with my user library though. Is just defining a malloc function in my library enough? or will I run into problems trying to define a function that is already in the c standard library?

yizzlez
  • 8,757
  • 4
  • 29
  • 44
Keeto
  • 4,074
  • 9
  • 35
  • 58
  • Hmm, be more specific. If the user allocates memory, per say with `new` (C++) tag, would you want your `malloc` to be called? What if a STL library function calls `new`? – yizzlez May 13 '14 at 20:55
  • yes. new or malloc in his source code should be implemented by my implementation of malloc. – Keeto May 13 '14 at 20:57
  • 1
    @Keeto, the solution to your predicament will most likely differ depending on the language. I suggest that you first remove either the [c++] or the [c] tag. – Mahonri Moriancumer May 13 '14 at 21:03
  • @Keeto, if you elect the [c] route, it would be helpful to know more about the execution environment (ie: Windows, Linux, OS X, etc.). – Mahonri Moriancumer May 13 '14 at 21:05
  • @Keeto, are you just implementing 'malloc()'? What about 'free()', 'realloc()', 'strdup()', etc. ? – Mahonri Moriancumer May 13 '14 at 21:08

0 Answers0