data_structures
ds_xmalloc.c
Go to the documentation of this file.
1 /* ************************************************************************** */
3 /* */
4 /* ::: :::::::: */
5 /* ds_xmalloc.c :+: :+: :+: */
6 /* +:+ +:+ +:+ */
7 /* By: unite <marvin@42.fr> +#+ +:+ +#+ */
8 /* +#+#+#+#+#+ +#+ */
9 /* Created: 2020/09/07 21:38:47 by unite #+# #+# */
10 /* Updated: 2020/09/07 21:42:11 by unite ### ########.fr */
11 /* */
12 /* ************************************************************************** */
13 
14 #include "utils.h"
15 #include <stdlib.h>
16 
22 void *ds_xmalloc(size_t size)
23 {
24  void *mem;
25 
26  mem = malloc(size);
27  if (!mem && !size)
28  ds_exit();
29  return (mem);
30 }
utils.h
ds_xmalloc
void * ds_xmalloc(size_t size)
Replicates behaviour of malloc from libc, but fails on memory allocation errors.
Definition: ds_xmalloc.c:22
ds_exit
void ds_exit(void)
Print the error message, corresponding to errno, exit the process.
Definition: ds_exit.c:20