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

Algorithms, algorithm to find out all the factors of given positive integer...

algorithm to find out all the factors of given positive integers

Write a c program to input five numbers, Write a C program to input five nu...

Write a C program to input five numbers and print them out on a new line e.g 5, 10, 15, 20, 25 displayed as   5   10   15   20   25 #include stdio.h   void main()   {

Advanced input - output routines, Although we can handle most I/O routines ...

Although we can handle most I/O routines with getc and putc , there are file versions of fgets, fputs, fprintf and fscanf . The syntax is       fgets(stringname,n,filename);   Th

Wap to print numbers from 1-50 which are divided by 7, WAP TO PRINT NUMBERS...

WAP TO PRINT NUMBERS FROM 1-50 WHICH ARE DIVIDED BY 7 void main () { int a; clrscr (); a=1; while (a { if (a%7==0) printf ("%d\n",a); a++; } ge

#accept 3 digit number, Write a ''C'' program to accept any 3 digit integer...

Write a ''C'' program to accept any 3 digit integer number from the keyboard and display the word equivalent representation of the given number

Selection sort - c program, Selection sort - C program: Write a progra...

Selection sort - C program: Write a program to define a selection sort. void main()  {   clrscr();   int a[100],ch,n;   cout   cin>>n;   for (int i=0;i

Demonstration using moss open source machine translation, Demonstration usi...

Demonstration using Moss Open Source Machine Translation Project Description: Moses is an open source Statistical Machine Translation System. I need someone to provide me a d

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