Skip to content

Commit 48f41ff

Browse files
committed
First commit.
0 parents  commit 48f41ff

20 files changed

+2031
-0
lines changed

AllocFunctions.c

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//################################################################
2+
//############ Date: June 29 2015
3+
//############ Author: Vincent Dary
4+
//############ File: AllocFunctions.c
5+
//############ Licence: GPLv3
6+
//############ Description: memory allocation function.
7+
//################################################################
8+
9+
#include "AllocFunctions.h"
10+
11+
// Performs a memory allocation.
12+
//
13+
// parameters:
14+
// alloSize: the memory allocation size
15+
// sizeType: the size type of the memory allocation
16+
//
17+
// return: a pointer to the new memory block or NULL if it fails.
18+
//
19+
void * mem_alloc(const size_t allocSize, size_t sizeType)
20+
{
21+
void *ptr = NULL;
22+
23+
if(allocSize == 0 || sizeType == 0)
24+
return NULL;
25+
26+
ptr = malloc(allocSize * sizeType);
27+
28+
if(ptr == NULL)
29+
{
30+
printf("[-] %s : %s\n", __FUNCTION__, strerror(errno));
31+
return NULL;
32+
}
33+
34+
return ptr;
35+
}
36+

AllocFunctions.h

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//################################################################
2+
//############ Date: June 29 2015
3+
//############ Author: Vincent Dary
4+
//############ File: AllocFunctions.h
5+
//############ Licence: GPLv3
6+
//############ Description: memory allocation function.
7+
//################################################################
8+
9+
#ifndef ALLOCFUNCTIONS_H_INCLUDED
10+
#define ALLOCFUNCTIONS_H_INCLUDED
11+
12+
#include <stdlib.h>
13+
#include <stdio.h>
14+
#include <errno.h>
15+
#include <string.h>
16+
17+
void * mem_alloc(const size_t allocSize, size_t sizeType);
18+
19+
#endif

0 commit comments

Comments
 (0)