-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalloc.h
More file actions
34 lines (29 loc) · 1.03 KB
/
alloc.h
File metadata and controls
34 lines (29 loc) · 1.03 KB
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
27
28
29
30
31
32
33
34
#ifndef SIMPLE_SHELL_ALLOC_H
#define SIMPLE_SHELL_ALLOC_H
#include <stdlib.h> /* malloc */
#include <stdio.h> /* perror */
#include <inttypes.h> /* intmax_t */
/**
* dup_func - a function that duplicates an object.
* @data: pointer to the object to be duplicated.
*
* Return: pointer to the duplicate, NULL on failure.
*/
typedef void *(dup_func)(void const *const data);
/**
* delete_func - a function that deletes an object.
* @data: pointer to the object to delete.
*/
typedef void(delete_func)(void *const data);
void *_malloc(const intmax_t size);
void *_calloc(const intmax_t n, const intmax_t type_size);
void *_free(void *nullable_ptr);
void *_realloc(void *mem, const intmax_t size, const intmax_t old_size);
void *_realloc_free_on_fail(
void *mem, const intmax_t size, const intmax_t old_size);
void *delete_2D_array(
void **array, intmax_t size, delete_func *free_row);
void **dup_2D_array(
void *const *const array, const intmax_t size,
dup_func *copy_data, delete_func *free_data);
#endif /* SIMPLE_SHELL_ALLOC_H */