This is what my code looks... i ddnt copy pastet the codes inside the functions because they are too long(about 300 lines)... i will put them if u want it....
i dont need the word static rite?
Code:
#include <stdio.h>
#include <sys/types.h>
#include <errno.h>
#ifndef NEWMALLOC_H
#define NEWMALLOC_H
/*-- PREPROCESSOR SUBSTITIUTIONS --*/
// Core Basics
#define MEMSIZE 50000 // Size of the Memory.(maximum is 65534, better to be an Even)
#define MAS 8 // Minimum Allocation Size Permited in Bytes.
#define MALLOCDATA 8 // Size of the data section of the Memory in Bytes.
// Pointers in Data Section
#define FREEHEAD 0 // Head Pointer
#define SIZE 1 // Local Variable for storing the size
#define PREVIOUS 2 // Previous Pointer
#define CURRENT 3 // Current Pointer
// nested(2nd level) directives
#define ARRAYSIZE (MEMSIZE/2)
#define MAXALLOWEDSIZE (MEMSIZE - MALLOCDATA)
#define ENDOFNEXT MEMSIZE // End of Next links
/*-- MEMORY DEFINITION AND DATA SECTION INITIALIZATION --*/
/*
----------------------------------------------------------------------------------
initialize to,
[FREEHEAD][SIZE][PREVIOUS][CURRENT][B_Next][B_Prev][B_Free][].....[]
FREEHEAD = MALLOCDATA+4
SIZE = 0
PREVIOUS = 0
CURRENT = 0
B_Next = ENDOFNEXT // end of Next links
B_Prev = 0 // end of Prev links
B_Free = 0 // end of Free links
----------------------------------------------------------------------------------
*/
unsigned short NEWMALLOC_mem[ARRAYSIZE] = { (MALLOCDATA+4), 0, 0, 0, ENDOFNEXT, 0, 0};
void * NewMalloc(size_t size)
{
// long code
}
void NewFree(void * location)
{
// long code
}
#endif