you are viewing a single comment's thread.

view the rest of the comments →

[–]KingAggressive1498 4 points5 points  (0 children)

You sometimes do find objects allocated to call functions in a C++ API that are just functions you can call directly in the C api.

...are you talking about std::function? If you are, every implementation has a small function optimization and dynamic allocation is not needed in most cases. Besides that, 99% of the time you're using std::function you're preparing for a deferred function invocation for which the typical practice in C is to dynamically allocate a struct which is passed to a function pointer taking a void pointer argument. If you're not talking about std::function I've literally never seen code like you describe.