Memory management by c program, C/C++ Programming

Assignment Help:

Memory management by c program:

Write a program to memory management in c program

unsigned max( unsigned, unsigned );

 

int BaseMemBlocks::allocBlock( size_t sz )

{

    BlockList _FAR *temp = new( max(sz,blockSize) ) BlockList( curBlock-1 );

    if( temp == 0 )

        return 0;

    curBlock = temp+1;

    blockCount++;

    return 1;

}

 

void BaseMemBlocks::freeTo( unsigned term )

{

    PRECONDITION( blockCount >= term );

    while( blockCount > term )

        {

        BlockList _FAR *temp = curBlock-1;

        curBlock = (temp->next)+1;

        delete temp;

        blockCount--;

        }

}

 

void _FAR *MemStack::allocate( size_t sz )

{

    sz = max( 1, sz );

    if( sz > blockSize - curLoc )

        if( allocBlock( sz ) == 0 )

            return 0;

        else

            curLoc = 0;

    void _FAR *temp = block() + curLoc;

    curLoc += sz;

    return temp;

}


Related Discussions:- Memory management by c program

Give advantage of using nfs, Question: a) Give two uses of NFS. b) G...

Question: a) Give two uses of NFS. b) Give one advantage of using NFS. c) Explain the following lines as they would be interpreted in the /etc/exports file i. /usr/local

Fill an array of randomly generated integers, The task consists of two part...

The task consists of two parts which are both preferably implemented in one source file. Towards the end of this document you will find a code skeleton that you must assume. Start

Minimum total number of shelv, Write a program that finds the minimum total...

Write a program that finds the minimum total number of shelv, C/C++ Programming

Explain register variable, Explain Register Variable Computers have int...

Explain Register Variable Computers have internal registers, which are used to keep data temporarily, before any operation can be performed. Intermediate results of the calcula

C program to find the even words in the string, C Program to FIND THE EVEN ...

C Program to FIND THE EVEN WORDS IN THE STRING #include conio.h> #include stdio.h> void main() {           char a[50],temp;           int i=0,k=0,l[25],c=0,r=0;

201 it, overload assignment opertor to assign the data of one object to ant...

overload assignment opertor to assign the data of one object to anthor

Write the statements which are used to connect php, Write the statements wh...

Write the statements which are used to connect PHP with MySQL? Statements which can be used to connect PHP with MySQL is: $conn = mysql_connect('localhost'); echo $co

What is the significance of external declaration, Problem 1 What is the...

Problem 1 What is the difference between function declaration and function definition? 2 Write a recursive function to find sum of even numbers from 2 to 10. 3 List some

Constructor , What is constructor or ctor? need help

What is constructor or ctor? need help

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd