diff options
| author | Dominik Kaiser | 2024-03-21 15:23:26 +0100 |
|---|---|---|
| committer | Dominik Kaiser | 2024-03-21 15:23:26 +0100 |
| commit | 18df570cd98093147845adfa822db424109a343c (patch) | |
| tree | 3188edef346b4fcd03c7c08c76a4b4f46d5aa41d /get_next_line_utils.c | |
| parent | 94b47301589acbc1ac7e75dd93b183a796cc9bad (diff) | |
| download | get_next_line-18df570cd98093147845adfa822db424109a343c.tar.gz get_next_line-18df570cd98093147845adfa822db424109a343c.zip | |
Remove old code and add str_realloc()
Code doesn't work at all after this but I have to refactor it anyways.
Diffstat (limited to 'get_next_line_utils.c')
| -rw-r--r-- | get_next_line_utils.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/get_next_line_utils.c b/get_next_line_utils.c index c1b5c58..d6fc37a 100644 --- a/get_next_line_utils.c +++ b/get_next_line_utils.c @@ -6,8 +6,30 @@ /* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/15 14:14:59 by dkaiser #+# #+# */ -/* Updated: 2024/03/15 14:15:08 by dkaiser ### ########.fr */ +/* Updated: 2024/03/21 15:22:40 by dkaiser ### ########.fr */ /* */ /* ************************************************************************** */ #include "get_next_line.h" + +char * str_realloc(char *str, size_t size) +{ + char *result; + size_t i; + + result = malloc(size); + if (!result) + { + free(str); + return NULL; + } + i = 0; + while (str[i]) + { + result[i] = str[i]; + i++; + } + while (i < size) + result[i++] = '\0'; + return result; +} |
