diff options
| author | Charles <sircharlesaze@gmail.com> | 2019-11-10 10:37:51 +0100 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2019-11-13 09:00:43 +0100 |
| commit | 3f2ef05278d42233f0a9ee9652e152824a7103e4 (patch) | |
| tree | 8fde8cdc22ffd77f1d23b35830d51bba129d70ad /utils.c | |
| parent | dafee6410a4ecd7400a83adf84ded3621f30a365 (diff) | |
| download | ft_printf-3f2ef05278d42233f0a9ee9652e152824a7103e4.tar.gz ft_printf-3f2ef05278d42233f0a9ee9652e152824a7103e4.tar.bz2 ft_printf-3f2ef05278d42233f0a9ee9652e152824a7103e4.zip | |
ft_printf write to buffer instead of instant write
Diffstat (limited to 'utils.c')
| -rw-r--r-- | utils.c | 27 |
1 files changed, 20 insertions, 7 deletions
@@ -6,7 +6,7 @@ /* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/10/29 00:12:40 by cacharle #+# #+# */ -/* Updated: 2019/11/05 23:46:14 by cacharle ### ########.fr */ +/* Updated: 2019/11/13 08:49:58 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -91,12 +91,25 @@ char *ft_itoa_unsigned_base(long long unsigned int n, char *base) return (str); } -char *ft_strtoupper(char *str) +void *ft_memjoin_free(void *dst, int dst_size, void *src, int src_size) { - int i; + void *clone; - i = -1; - while (str[++i]) - str[i] = ft_toupper(str[i]); - return (str); + if (dst == NULL) + { + if ((dst = malloc(src_size)) == NULL) + return (NULL); + ft_memcpy(dst, src, src_size); + return (dst); + } + if ((clone = malloc(dst_size)) == NULL) + return (NULL); + ft_memcpy(clone, dst, dst_size); + free(dst); + if ((dst = malloc(dst_size + src_size)) == NULL) + return (NULL); + ft_memcpy(dst, clone, dst_size); + free(clone); + ft_memcpy(dst + dst_size, src, src_size); + return (dst); } |
