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;


    return 1;



void BaseMemBlocks::freeTo( unsigned term )


    PRECONDITION( blockCount >= term );

    while( blockCount > term )


        BlockList _FAR *temp = curBlock-1;

        curBlock = (temp->next)+1;

        delete temp;





void _FAR *MemStack::allocate( size_t sz )


    sz = max( 1, sz );

    if( sz > blockSize - curLoc )

        if( allocBlock( sz ) == 0 )

            return 0;


            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 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

Implementation of the Dictionary class: int Dictionary::find_word(char *s) {    char word[81];    for (int i = 0; i       if (stricmp(words[i].get_word(word),s) =

What is Ms dos?

Data array A has data series from 1,000,000 to 1 with step size 1, which is in perfect decreasing order. Data array B has data series from 1 to 1,000,000, which is in random order.

Access privileges 1. If the designer of the base class needs no one, not even a derived class to access a member, then that member should be made private. 2. If the designer

C Coding 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 be found

make a marksheet of 2 student with 5 subject

write a program to find the area under curve y=f(x) between x=a and x=b,integrate y=f(x) between the limits a and b

Write a function that has two int parameters num and n, and returns TRUE when the nth bit in num is 1, otherwise FALSE. This function should use the function in the above problem.