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

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;

}

Posted Date: 10/19/2012 2:58:43 AM | Location : United States







Related Discussions:- Memory management by c program, Assignment Help, Ask Question on Memory management by c program, Get Answer, Expert's Help, Memory management by c program Discussions

Write discussion on Memory management by c program
Your posts are moderated
Related Questions
Problem: a) Give and Illustrate with the help of diagrams, four topologies for the Network Information System (NIS). b) Give methods for creating user accounts and groups.

Question: (a) (i) Explain how class members can be accessed when using objects of the class. Use a suitable example to illustrate your answer. (ii) Explain how the privat

Program is to define a class as student: Program is to define a class as student and display the records specific depending upon the number class student  {  private:

TO CONVERT A NUMBER OR A DIGIT INTO ALPHABET

Aim: To implement a program to maintain information of employees in an educational institute using inheritance. Code:                       class staff {

A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your task is to convert S to palindrome

Define Passing Structure to a Function? A structure is able to be passed as a function argument identical to any other variable. If we are merely interested in one member of a

exemples of many to many

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

Want a scraping program created Project Description: We need to hire a professional developer to scrape the site for information such as *product title *Product Price