-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathext_alloc.h
More file actions
21 lines (17 loc) · 839 Bytes
/
Copy pathext_alloc.h
File metadata and controls
21 lines (17 loc) · 839 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#ifndef _EXT_ALLOC_H_
#define _EXT_ALLOC_H_
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#define GET_ARRAY_SIZE(arr) sizeof(arr) / sizeof(arr[0])
#define s_free(ptr) (free(ptr), ptr = NULL)
#define smart_realloc(type, block, size) (type *)realloc(block, sizeof(type) * size)
#define smart_malloc(type, size) (type * )malloc(sizeof(type) * size)
#define smart_calloc(type, size) size ? (type * )calloc(size, sizeof(type)) : NULL
bool safety_realloc(void** block, uint32_t now_index, uint32_t* now_size, uint32_t type_size);
bool clamp_realloc(void** block, uint32_t clamp_cap, uint32_t* now_cap, uint32_t type_size);
void* dupalloc(const void* src_block, size_t size);
#define smart_dupalloc(type, block) dupalloc(block, sizeof(type))
#endif // !_EXT_ALLOC_H_