thannara123
Advanced Member level 5
trying to understand the following function.
Can I get the correct working?
For more https://stackoverflow.com/questions...ram-char-allocc-kr-page-101/36245596#36245596
May i get any simple example program in microcontroler section by calloc() function .
Can I get the correct working?
Code:
[COLOR=gray][FONT=Consolas]#define[/FONT][/COLOR][COLOR=black][FONT=Consolas] ALLOCSIZE [/FONT][/COLOR][COLOR=maroon][FONT=Consolas]1000[/FONT][/COLOR][/FONT][/COLOR]
[COLOR=black]
[/COLOR][COLOR=#00008B]static[/COLOR][COLOR=black] [/COLOR][COLOR=#00008B]char[/COLOR][COLOR=black] allocbuf[/COLOR][COLOR=black][[/COLOR][COLOR=black]ALLOCSIZE[/COLOR][COLOR=black]];[/COLOR][COLOR=black]
[/COLOR][COLOR=#00008B]static[/COLOR][COLOR=black] [/COLOR][COLOR=#00008B]char[/COLOR][COLOR=black] [/COLOR][COLOR=black]*[/COLOR][COLOR=black]allocp [/COLOR][COLOR=black]=[/COLOR][COLOR=black] allocbuf[/COLOR][COLOR=black];[/COLOR][COLOR=black]
[/COLOR][COLOR=#00008B]char[/COLOR][COLOR=black] [/COLOR][COLOR=black]*[/COLOR][COLOR=black]alloc[/COLOR][COLOR=black]([/COLOR][COLOR=#2B91AF]int[/COLOR][COLOR=black] n[/COLOR][COLOR=black])[/COLOR][COLOR=black]
[/COLOR][COLOR=black]{[/COLOR][COLOR=black]
[/COLOR][COLOR=#00008B]if[/COLOR][COLOR=black]([/COLOR][COLOR=black]allocbuf [/COLOR][COLOR=black]+[/COLOR][COLOR=black] ALLOCSIZE [/COLOR][COLOR=black]-[/COLOR][COLOR=black] allocp [/COLOR][COLOR=black]>=[/COLOR][COLOR=black] n[/COLOR][COLOR=black])[/COLOR][COLOR=black]
[/COLOR][COLOR=black]{[/COLOR][COLOR=black]
allocp [/COLOR][COLOR=black]+=[/COLOR][COLOR=black] n[/COLOR][COLOR=black];[/COLOR][COLOR=black]
[/COLOR][COLOR=#00008B]return[/COLOR][COLOR=black] allocp [/COLOR][COLOR=black]-[/COLOR][COLOR=black] n[/COLOR][COLOR=black];[/COLOR][COLOR=black]
[/COLOR][COLOR=black]}[/COLOR][COLOR=black]
[/COLOR][COLOR=#00008B]else[/COLOR][COLOR=black]
[/COLOR][COLOR=#00008B]return[/COLOR][COLOR=black] [/COLOR][COLOR=maroon]0[/COLOR][COLOR=black];[/COLOR][COLOR=black] [/COLOR][COLOR=#222426][FONT=Arial][COLOR=black][FONT=Consolas]}[/FONT][/COLOR]
For more https://stackoverflow.com/questions...ram-char-allocc-kr-page-101/36245596#36245596
May i get any simple example program in microcontroler section by calloc() function .