-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathAllocFunctions.c
36 lines (29 loc) · 967 Bytes
/
AllocFunctions.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
27
28
29
30
31
32
33
34
35
//################################################################
//############ Date: June 29 2015
//############ Author: Vincent Dary
//############ File: AllocFunctions.c
//############ Licence: GPLv3
//############ Description: memory allocation function.
//################################################################
#include "AllocFunctions.h"
// Performs a memory allocation.
//
// parameters:
// alloSize: the memory allocation size
// sizeType: the size type of the memory allocation
//
// return: a pointer to the new memory block or NULL if it fails.
//
void * mem_alloc(const size_t allocSize, size_t sizeType)
{
void *ptr = NULL;
if(allocSize == 0 || sizeType == 0)
return NULL;
ptr = malloc(allocSize * sizeType);
if(ptr == NULL)
{
printf("[-] %s : %s\n", __FUNCTION__, strerror(errno));
return NULL;
}
return ptr;
}