]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-sizeof: show stack and heap randomization
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 26 Nov 2021 09:28:18 +0000 (10:28 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 30 Nov 2021 21:55:15 +0000 (22:55 +0100)
It's useful to reassure yourself those those things actually work ;)

src/test/test-sizeof.c

index e86844b8ce027caaab7392d0a98c62077fa1de68..f349852553de011e81028e8b32ca26a94c445d8b 100644 (file)
@@ -93,5 +93,13 @@ int main(void) {
 
         printf("timeval: %zu\n", sizeof(struct timeval));
         printf("timespec: %zu\n", sizeof(struct timespec));
+
+        void *x = malloc(100);
+
+        printf("local variable: %p\n", &function_pointer);
+        printf("glibc function: %p\n", memcpy);
+        printf("heap allocation: %p\n", x);
+        free(x);
+
         return 0;
 }