Question: provide me all the files with all the functions implemented with proper code. file: fscMalloc.h #ifndef FSCMALLOC _ H #define FSCMALLOC _ H #ifdef _
provide me all the files with all the functions implemented with proper code.
file: fscMalloc.h
#ifndef FSCMALLOCH
#define FSCMALLOCH
#ifdef cplusplus
extern C
#endif
#include
#include
typedef struct
sizet size;
int magic;
fscallocheadert;
typedef struct fscnodet
sizet size;
struct fscnodet next;
fscfreenodet;
typedef struct
fscfreenodet head;
int magicNumber;
memoryStructure;
typedef enum
FIRSTFITRETURNFIRST,
FIRSTFITRETURNSECOND,
BESTFITRETURNFIRST,
BESTFITRETURNSECOND,
WORSTFITRETURNFIRST,
WORSTFITRETURNSECOND,
NEXTFITRETURNFIRST,
NEXTFITRETURNSECOND
fscAllocationMethod;
enum MBToB ;
void fscMemorySetupmemoryStructure fscAllocationMethod, sizet sizeInBytes;
void fscMallocmemoryStructure sizet sizeInBytes; returns memory, if failure
void fscFreememoryStructure void ; returns memory to the pool
void fscMemoryCleanupmemoryStructure;
void printFreeListFILE out, fscfreenodet head;
#ifdef cplusplus
#endif
#endif FSCMALLOCH
file: fscMalloc.c
#include "fscMalloc.h
#include
#include
#include for rand
#include for the init of rand
#include for sizet
void fscMemorySetupmemoryStructure m fscAllocationMethod am sizet sizeInBytes
if FIRSTFITRETURNFIRST am
fprintfstderr "This code only supports the FIRSTFITRETURNFIRST allocation method
;
return ;
You need to write the code here
return ;
void fscMallocmemoryStructure m sizet requestedSizeInBytes
You need to write the code here
void fscFreememoryStructure m void returnedMemory
Given a node, prints the list for you.
void printFreeListFILE out, fscfreenodet head
given a node, prints the list.
fscfreenodet current head;
fprintfout "About to dump the free list:
;
while current
fprintfout
"Node address: ut Node size stored: ut Node size actualut Node next:u
current,
currentsize,
currentsize sizeof fscfreenodet
currentnext;
current currentnext;
file: main.c
#include
#include
#include "memoryTest.h
#include
int mainint argc, char argv
setlocaleLCNUMERIC,"";
if memoryTestOne
fprintfstderr"Failure in memory test one";
exit EXITFAILURE;
if memoryTestTwo
fprintfstderr"Failure in memory test two";
exit EXITFAILURE;
if memoryTestThree
fprintfstderr"Failure in memory test three";
exit EXITFAILURE;
printfTests Succeeded";
return EXITSUCCESS;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
