chiark / gitweb /
alloc-util: cleanups
authorAlexander Kuleshov <kuleshovmail@gmail.com>
Tue, 16 Feb 2016 17:51:43 +0000 (23:51 +0600)
committerSven Eden <yamakuzure@gmx.net>
Fri, 16 Jun 2017 08:12:57 +0000 (10:12 +0200)
commit5216c93baebfa4e129ea1fc6fffd2c842aaea839
tree8a54071f9f7f9dcebd2748724521231d386cc42a
parentda1f9afa7ea68d5bb00b7dc4b704ba15226268be
alloc-util: cleanups

This patch contains a set of little cleanups for alloc-util.h:

1. The malloc_multiply(), realloc_multiply() and memdup_multiply()
functions check allocation related parameters on overflow. Let's
move them to the separate size_multiply_overflow() function for
simplicity, code duplication prevention and possible reuse in future.

2. use SIZE_MAX from stdlib instead of ((size_t) - 1) to be more
clear.

3. The 'a'/'b' variables are renamed to 'size' and 'need' to be
more clear.'
src/basic/alloc-util.h