Is replacing alloca(3) where possible a good thing to do?

Joerg Sonnenberger joerg at bec.de
Wed Sep 14 11:58:32 UTC 2016


On Wed, Sep 14, 2016 at 01:46:35PM +0200, Ed Schouten wrote:
> So the best solution is to replace any use of alloca() with
> malloc()/free(). That said, as you were interested in making such
> changes in cddl/*, I guess you'll also have to go through the process
> of sending those patches to Illumos.

Blindly replacing them makes little sense. alloca provides zero-cost
freeing and is also much cheaper than malloc. It should be limited to
reasonable sizes though, where reasonable is typically < 1MB per
thread.

Joerg


More information about the freebsd-hackers mailing list