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
A: Here are a few of the many instance of operator overloading: myString + yourString may concatenate two std::string objects myDate++ may increment a Date object a * b may m

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

Program is to search for a given character in a string: Program is to search for a given character in a string and print point of match char *stsearch(char *string, char sea

Conversion between Objects of Different Classes As the compiler does not know anything about the user-defined type, the conversion instructions are to be specified in a functio

Reference Oddities A reference variable can demote to any integer variable, be it in an array or a member variable from structure or class. Reference variables can demote to co

Write a program that accepts two real numbers from a user and a select code. If the entered select code is 1, have the program add the two previously entered numbers and display t

write a C program for padovan string for a natural number   program 1 : package test.padovanstring; public class PadovanString {     public int stringOccurrences(int n,

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

HWID Spoofer for Windows 7, 8 x64 Project Description: I want a simple program that will spoof my hardware id. I should be able to prepare the id to spoof to in the program a