From e3917966f16485f85b023f1ae36bc44b4a5f8171 Mon Sep 17 00:00:00 2001 From: FreeArtMan Date: Tue, 9 Aug 2022 11:03:33 +0100 Subject: Add stack --- md/notes/undefined_c/titles.md | 43 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/md/notes/undefined_c/titles.md b/md/notes/undefined_c/titles.md index 2c5bcd1..92b35ab 100644 --- a/md/notes/undefined_c/titles.md +++ b/md/notes/undefined_c/titles.md @@ -239,10 +239,51 @@ Now size of structure will be 32. All results on amd64, other arch may differ. +### How to shoot leg +Forget that struct size is not consistent. +### Recursion + +Recursion is technique that could be useful to write shorter code +and deal with cycles. One thing that recursion suffer is that it consumes +stack memory and its have default limit on platform. + +```c +#include +#include + +int fun_r(int i) { + printf("val %d\n",i); + fun_r(i+1); + return 0; +} + +int main() +{ + fun_r(0); +} +``` + +Program will fail after its reach out of stack range. +When increase the default stack limit it go more further. + + +Check default stack size + +``` +ulimit -s +``` + +Set stack size + +``` +ulimit -s 16384 +``` -### Recursion ### Macro + + + ### Signed/Unsigned ### Pointers ### Endianess -- cgit v1.2.3