Function without name
_malloc_message
is a function pointer.
Somewhere in the code you will find the definition of a function whose prototype is like this:
void foo (const char* p1, const char* p2, const char* p3, const char* p4);
Then you assign the function to the function pointer like this:.
_malloc_message = foo;
and call it like this:
(*_malloc_message)(p1, p2, p3, p4);
The question is why you cannot call foo directly. One reason is that you know that foo needs to be called only at runtime.
_malloc_message is defined in malloc.c of jemalloc:
This is how you may use it:
extern void malloc_error_logger(const char *p1, const char *p2, const char *p3, const char *p4)
{
syslog(LOG_ERR, "malloc error: %s %s %s %s", p1, p2, p3, p4);
}
//extern
_malloc_message = malloc_error_logger;
malloc_error_logger()
would be called on various malloc library errors. malloc.c has more details.
It isn't a function. It's a declaration saying that _malloc_message
is a pointer to a function, with return type void
and the parameters as given.
In order to use it, you'd have to assign to it the address of a function with that arity, return type, and parameter types.
Then you'd use _malloc_message
as if it were a function.