๐calloc
โ๏ธ ํจ์ ํ๋กํ ํ์
void *calloc(size_t count, size_t size);
โ๏ธ ํจ์์ ์ญํ : size ๋ฐ์ดํธ์ ๋ณ์๋ฅผ count ๊ฐ ์ ์ฅํ ์ ์๋ ๊ณต๊ฐ์ ํ ๋นํ๊ณ 0์ผ๋ก ์ด๊ธฐํ
โ๏ธํจ์ ๋ฐํ๊ฐ
โ๏ธ ์ฑ๊ณต์, ํ ๋น๋ ๋ฉ๋ชจ๋ฆฌ์ ํฌ์ธํฐ
โ๏ธ ์คํจ์, NULL
โ๏ธ man page์ ๋์จ ์ค๋ช !
๐ Description
The calloc() function contiguously allocates enough space for count objects that are size bytes of memory each and returns a pointer to the allocated memory. The allocated memory is filled with bytes of value zero.
โฟํด์ : calloc() ํจ์๋ ์ฐ์์ ์ผ๋ก size๋ฐ์ดํธ์ธ count๊ฐ์ object๋ฅผ ์ํ ์ถฉ๋ถํ ๊ณต๊ฐ์ ํ ๋นํ๋ค. ํ ๋น๋ ๋ฉ๋ชจ๋ฆฌ๋ 0์ ๊ฐ์ ๊ฐ์ง byte๋ค๋ก ์ฑ์์ง๋ค.
๐ Return Values
If successful, calloc() function returns a pointer to allocated memory. If there is an error, they return a NULL pointer and set errno to ENOMEM.
โฟํด์ : ๋ง์ฝ ์ฑ๊ณต์ ์ด๋ผ๋ฉด, calloc() ํจ์๋ ํ ๋น๋ ๋ฉ๋ชจ๋ฆฌ์ ํฌ์ธํฐ๋ฅผ ๋ฐํํ๋ค. ๋ง์ฝ ์๋ฌ๊ฐ ์๋ค๋ฉด NULLํฌ์ธํฐ๋ฅผ ๋ฐํํ๊ณ ENOMEM์ errno๋ฅผ ์ค์ ํ๋ค.
calloc์ malloc๊ณผ ๋ฌ๋ฆฌ 0์ผ๋ก ์ด๊ธฐํ๋ฅผ ํด์ค.
'๐ฐ42์์ธ > libft' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[42์์ธ] libft ์ ๋ฆฌ : ft_strlen, ft_strlcpy, ft_strlcat ๊ตฌํ (0) | 2022.02.07 |
---|---|
[42์์ธ] libft ์ ๋ฆฌ : ft_toupper, ft_tolower ๊ตฌํ (0) | 2022.01.14 |
[42์์ธ] libft ์ ๋ฆฌ : ft_isalpha, ft_isdigit, ft_isalnum, ft_isascii, ft_isprint ๊ตฌํ (0) | 2022.01.13 |
[42์์ธ] libft ์ ๋ฆฌ: strdup (0) | 2022.01.05 |
[42์์ธ] libft ์ ๋ฆฌ : strnstr (0) | 2022.01.04 |