mirror of
https://github.com/shadow-maint/shadow.git
synced 2026-01-26 22:12:26 +00:00
If we consider simple objects as arrays of size 1, we can considerably
simplify these APIs, merging the *ARRAY and the non-array variants.
That will produce more readable code, since lines will be shorter (by
not having ARRAY in the macro names, as all macros will consistently
handle arrays), and the allocated size will be also more explicit.
The syntax will now be of the form:
p = MALLOC(42, foo_t); // allocate 42 elements of type foo_t.
p = MALLOC(1, bar_t); // allocate 1 element of type foo_t.
The _array() allocation functions should _never_ be called directly, and
instead these macros should be used.
The non-array functions (e.g., malloc(3)) still have their place, but
are limited to allocating structures with flexible array members. For
any other uses, the macros should be used.
Thus, we don't use any array or ARRAY variants in any code any more, and
they are only used as implementation details of these macros.
Link: <https://software.codidact.com/posts/285898/288023#answer-288023>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
This testsuite is NOT SECURE: it will temporarily change your passwords file with known passwords. You should run it on a chroot, or on a secured dedicated system. To test a Debian system: $ mkdir sid-chroot $ sudo debootstrap sid sid-chroot/ http://deb.debian.org/debian/ edit or copy a sources.list $ sudo cp /etc/apt/sources.list sid-chroot/etc/apt/ edit or copy a resolv.conf $ sudo cp /etc/resolv.conf sid-chroot/etc/ $ su - root -c "chroot sid-chroot/ /bin/bash" # mount -t proc proc /proc # mount -t devpts devpts /dev/pts # aptitude update # aptitude install expect # cd /dev ; mknod --mode=666 /dev/ptmx c 5 2