Date: Mon, 16 Nov 1998 22:17:47 -0700 From: Nate Williams <nate@mt.sri.com> To: hackers@FreeBSD.ORG Subject: Wrapping a function Message-ID: <199811170517.WAA22627@mt.sri.com>
next in thread | raw e-mail | index | archive | help
Does anyone have an easy way of 'wrapping' an already existing library function so that any programs linked against your .o will call your function, but so your function can call the 'real' library function? Example: my_malloc.c: void *malloc(size_t size) { void *ret; printf("Calling malloc\n"); ret = REALMALLOC(size); printf("Leaving malloc\n"); return ret; } Ignoring all of the functions where there is loss of errno and such, are they any good ideas? Note, the use of the dl* functions is explicitly not allowed since those happen to be the functions I want to wrap in this case. I'm at a loss here how to do this in C, so any good hacks are welcomed. Nate To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199811170517.WAA22627>