Home  >  Q&A  >  body text

c++ - What does static void (* __set_malloc_handler(void (*__f)()))() mean

static void (* __set_malloc_handler(void (*__f)()))()

void (*func)()I understand this, but what does the above __f do, and how to call the above function?

曾经蜡笔没有小新曾经蜡笔没有小新2715 days ago982

reply all(1)I'll reply

  • 巴扎黑

    巴扎黑2017-06-05 11:13:30

    Disassemble the analysis layer by layer
    The innermost __f is a function pointer, its parameter is void, and the return value is void.
    Then __set_malloc_handler is relatively easy to confuse. First of all, it is a function (I said it wrong at first, not a pointer). Its parameters are function pointers in the shape of __f, and its return value is a pointer. The type of this pointer is void. (*)()
    The usage should be as follows:

    void (*foo)();
    void (*bar)();
    foo = __set_malloc_handler(bar);

    reply
    0
  • Cancelreply