provide me all the files with all the functions implemented with proper code.file: fscMalloc.h #ifndef FSCMALLOC_H#define FSCMALLOC_H#ifdef __cplusplusextern "C" {#endif     #include <stddef.h>     #include <stdio.h>     typedef struct {        size_t size;        int magic;    } fsc_alloc_header_t;        typedef struct _fsc_node_t {        size_t size;        struct _fsc_node_t* next;    } fsc_free_node_t;         typedef struct {        fsc_free_node_t* head;        int magicNumber;    } memoryStructure;     typedef enum {        FIRST_FIT_RETURN_FIRST,        FIRST_FIT_RETURN_SECOND,        BEST_FIT_RETURN_FIRST,        BEST_FIT_RETURN_SECOND,        WORST_FIT_RETURN_FIRST,        WORST_FIT_RETURN_SECOND,        NEXT_FIT_RETURN_FIRST,        NEXT_FIT_RETURN_SECOND    } fscAllocationMethod;    enum { MBToB = 1048576 };     void* fscMemorySetup(memoryStructure*, fscAllocationMethod, size_t sizeInBytes);    void* fscMalloc(memoryStructure*, size_t sizeInBytes); // returns memory, 0 if failure    void fscFree(memoryStructure*, void *); // returns memory to the pool    void fscMemoryCleanup(memoryStructure*);    void printFreeList(FILE * out, fsc_free_node_t* head); #ifdef __cplusplus}#endif #endif /* FSCMALLOC_H */ file: fscMalloc.c #include "fscMalloc.h"#include <assert.h>#include <sys/mman.h>#include <stdlib.h> /* for rand() */#include <time.h> /* for the init of rand */#include <stddef.h> /* for size_t */ void* fscMemorySetup(memoryStructure* m, fscAllocationMethod am, size_t sizeInBytes) {    if (FIRST_FIT_RETURN_FIRST != am) {        fprintf(stderr, "This code only supports the FIRST_FIT_RETURN_FIRST allocation method\n");        return 0;    }     /* You need to write the code here     */    return 0;} void* fscMalloc(memoryStructure* m, size_t requestedSizeInBytes) {        /* You need to write the code here     */} void fscFree(memoryStructure* m, void * returnedMemory) {} /* Given a node, prints the list for you. */void printFreeList(FILE * out, fsc_free_node_t* head) {    /* given a node, prints the list. */    fsc_free_node_t* current = head;    fprintf(out, "About to dump the free list:\n");    while (0 != current) {        fprintf(out,                "Node address: %'u\t Node size (stored): %'u\t Node size (actual) %'u\t Node next:%'u\n",                current,                current->size,                current->size + sizeof (fsc_free_node_t),                current->next);        current = current->next;    }}

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

provide me all the files with all the functions implemented with proper code.

file: fscMalloc.h

#ifndef FSCMALLOC_H
#define FSCMALLOC_H
#ifdef __cplusplus
extern "C" {
#endif

    #include <stddef.h> 
    #include <stdio.h> 
    typedef struct {
        size_t size;
        int magic;
    } fsc_alloc_header_t;
    
    typedef struct _fsc_node_t {
        size_t size;
        struct _fsc_node_t* next;
    } fsc_free_node_t;
    

    typedef struct {
        fsc_free_node_t* head;
        int magicNumber;
    } memoryStructure;

    typedef enum {
        FIRST_FIT_RETURN_FIRST,
        FIRST_FIT_RETURN_SECOND,
        BEST_FIT_RETURN_FIRST,
        BEST_FIT_RETURN_SECOND,
        WORST_FIT_RETURN_FIRST,
        WORST_FIT_RETURN_SECOND,
        NEXT_FIT_RETURN_FIRST,
        NEXT_FIT_RETURN_SECOND
    } fscAllocationMethod;
    enum { MBToB = 1048576 };

    void* fscMemorySetup(memoryStructure*, fscAllocationMethod, size_t sizeInBytes);
    void* fscMalloc(memoryStructure*, size_t sizeInBytes); // returns memory, 0 if failure
    void fscFree(memoryStructure*, void *); // returns memory to the pool
    void fscMemoryCleanup(memoryStructure*);
    void printFreeList(FILE * out, fsc_free_node_t* head);

#ifdef __cplusplus
}
#endif

#endif /* FSCMALLOC_H */


file: fscMalloc.c

#include "fscMalloc.h"
#include <assert.h>
#include <sys/mman.h>
#include <stdlib.h> /* for rand() */
#include <time.h> /* for the init of rand */
#include <stddef.h> /* for size_t */

void* fscMemorySetup(memoryStructure* m, fscAllocationMethod am, size_t sizeInBytes) {
    if (FIRST_FIT_RETURN_FIRST != am) {
        fprintf(stderr, "This code only supports the FIRST_FIT_RETURN_FIRST allocation method\n");
        return 0;
    }

    /* You need to write the code here
     */
    return 0;
}


void* fscMalloc(memoryStructure* m, size_t requestedSizeInBytes) {
        /* You need to write the code here
     */
}

void fscFree(memoryStructure* m, void * returnedMemory) {
}


/* Given a node, prints the list for you. */
void printFreeList(FILE * out, fsc_free_node_t* head) {
    /* given a node, prints the list. */
    fsc_free_node_t* current = head;
    fprintf(out, "About to dump the free list:\n");
    while (0 != current) {
        fprintf(out,
                "Node address: %'u\t Node size (stored): %'u\t Node size (actual) %'u\t Node next:%'u\n",
                current,
                current->size,
                current->size + sizeof (fsc_free_node_t),
                current->next);
        current = current->next;
    }
}



Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education