Hi
I'm really sorry if my questions are stupid.

Can someone please explain why we create wrapper function for standard library function? (Example: glib made wrapper function for malloc())

Why do we hook our program to standard library? (malloc, free, ...)


Thanks
Mark

I agree its stupid thing to do, unless of course the wrapper function does other things too.

Thanks for your reply.

I asked some programmers around a week ago and they told me if i want to create linked list, in order to be secure i need to hook my own malloc function to the api malloc.

Now I found an example on gnu C library on how to do that and i understood it. But why its is better to do a hook? what should i check in my hooked function beside of checking if the malloc (api) returns NULL?


Thanks
Mark

For example, your wrapper could keep track of all the memory allocated and deallocated. This would help you make sure you aren't attempting to deallocate twice, or not deallocating at all.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.