Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write C code for this memory allocation problem. Given are three files alloc.c , alloc.h and alloctest.c Your job is to write the freef()

Please write C code for this memory allocation problem.

Given are three files alloc.c , alloc.h and alloctest.c

Your job is to write the freef() function in the file alloc.c according to the pseudocode given below : image text in transcribed

The files are posted at the link because they are quite large to post it here. Please copy and paste it to the browser .

Alloc.c

https://justpaste.it/1l5fo

alloc.h

https://justpaste.it/2b2db

alloctest.c

https://justpaste.it/6r5b7

Put this files together and all you have to do is write freef() function in file alloc.c where it says "/* you write the code for the freef function here */

?

Pseudocode for freef(char *p) p is the same pointer obtained from alloc) Change tag to FREETAG on blockl Change tag to FREETAG on blockr No need to update size on blockl and blockr because alloc() sets the sizes correctly Check if block on left is also free? case 1: yes, coalesce free block on left and p case 2: no, enchain buffer Check if block on right is also free? case 3: yes, unchain the block on right and coalesce p with block on right. return Pseudocode for freef(char *p) p is the same pointer obtained from alloc) Change tag to FREETAG on blockl Change tag to FREETAG on blockr No need to update size on blockl and blockr because alloc() sets the sizes correctly Check if block on left is also free? case 1: yes, coalesce free block on left and p case 2: no, enchain buffer Check if block on right is also free? case 3: yes, unchain the block on right and coalesce p with block on right. return

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Relational Model A Retrospective Review And Analysis

Authors: C. J. Date

1st Edition

0201612941, 978-0201612943

More Books

Students also viewed these Databases questions

Question

Explain the alkaline nature of aqueous solution of making soda.

Answered: 1 week ago

Question

Comment on the pH value of lattice solutions of salts.

Answered: 1 week ago