-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathv_realloc.c
26 lines (23 loc) · 1.11 KB
/
v_realloc.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* v_realloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: glegendr <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/12/12 21:37:20 by glegendr #+# #+# */
/* Updated: 2019/11/19 21:13:49 by glegendr ### ########.fr */
/* */
/* ************************************************************************** */
#include "vector.h"
void *v_realloc(void *mem, int mem_size, int new_size)
{
void *tmp;
if ((tmp = malloc(new_size)) == NULL)
return (NULL);
if (mem == NULL)
return (tmp);
v_memcpy(tmp, mem, mem_size);
free(mem);
return (tmp);
}