> sbrk ~ Online tutorial

sbrk


 sbrk

                  <ALLOC.H>
     
Changes data-segment space allocation
Declaration:
   void *sbrk(int incr);
Remarks:
sbrk changes the allocated space by adding incr bytes to the break value.
The amount of allocated space increases as the break value increases.
With sbrk, incr can be negative, which decreases the amount of allocated
space.

Return Value:

sbrk returns the old break value
On error, both functions return -1 and
    set errno to ENOMEM (not enough memory).
Progarm
#include <stdio.h>
#include <alloc.h>

int main(void)
{
   printf("Changing allocation with sbrk()\n");
   printf("Before sbrk() call: %lu bytes free\n",
          (unsigned long) coreleft());
   sbrk(1000);
   printf(" After sbrk() call: %lu bytes free\n",
           (unsigned long) coreleft());
   return 0;
}

Please Give Us Your 1 Minute In Sharing This Post!
Please Give Us Your 1 Minute In Sharing This Post!
SOCIALIZE IT →
FOLLOW US →
SHARE IT →
Powered By: BloggerYard.Com

0 comments: