]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/test/test-alloc-util.c
2 This file is part of systemd.
4 Copyright 2010 Lennart Poettering
6 systemd is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
11 systemd is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License
17 along with systemd; If not, see <http://www.gnu.org/licenses/>.
20 #include "alloc-util.h"
24 static void test_alloca(void) {
25 static const uint8_t zero
[997] = { };
28 t
= alloca_align(17, 512);
29 assert_se(!((uintptr_t)t
& 0xff));
32 t
= alloca0_align(997, 1024);
33 assert_se(!((uintptr_t)t
& 0x1ff));
34 assert_se(!memcmp(t
, zero
, 997));
37 static void test_memdup_multiply(void) {
38 int org
[] = {1, 2, 3};
41 dup
= (int*)memdup_multiply(org
, sizeof(int), 3);
44 assert_se(dup
[0] == 1);
45 assert_se(dup
[1] == 2);
46 assert_se(dup
[2] == 3);
50 int main(int argc
, char *argv
[]) {
52 test_memdup_multiply();