-2

I want to replace all instances of '::memcpy()' with my custom made 'customMemcpy()' defined in a file 'Memory.h' in my project. This call is made from lot of places so doing it manually is pain. Is there any clever method to do it programmatically?

Jeff Mercado
  • 129,526
  • 32
  • 251
  • 272
polapts
  • 5,493
  • 10
  • 37
  • 49

3 Answers3

0

You can use wrapping mechanism, see http://sourceware.org/binutils/docs/ld/Options.html (find --wrap=symbol) for example. This way gives you acess both to your and original function.

vissi2
  • 83
  • 6
0
find . -name '*.cpp' -print0 | xargs -0 -l sed -i -e 's/\<memcpy\>/customMemcpy/' 
Robᵩ
  • 163,533
  • 20
  • 239
  • 308
0
#define memcpy(dst,src,size) custom_memcpy(dst, src, size)

void custom_memcpy(void* dst, const void* src, size_t size)
{
  //TODO: Implement Custom Memcpy
}
TVOHM
  • 2,740
  • 1
  • 19
  • 29