Heap Assignment/malloc.c
struct _block *growHeap(struct _block *last, size_t size) 
{
   /* Request more space from OS */
   struct _block *curr = (struct _block *)sbrk(0);
   struct _block *prev = (struct _block *)sbrk(sizeof(struct _block) + size);

   assert(curr == prev);

   /* OS allocation failed */
   if (curr == (struct _block *)-1) 
   {
      return NULL;
   }

   /* Update heapList if not set */
   if (heapList == NULL) 
   {
      heapList = curr;
   }

   /* Attach new _block to prev _block */
   if (last) 
   {
      last->next = curr;
   }

   /* Update _block metadata */
   curr->size = size;
   curr->next = NULL;
   curr->free = false;
   curr->prev = last;
   return curr;
}
/*
 * \brief growheap
 *
 * Given a requested size of memory, use sbrk() to dynamically 
 * increase the data segment of the calling process.  Updates
 * the free list with the newly allocated memory.
 *
 * \param last tail of the free _block list
 * \param size size in bytes to request from the OS
 *
 * \return returns the newly allocated _block of NULL if failed
 */
\brief growheap
Given a requested size of memory, use sbrk() to dynamically
increase the data segment of the calling process.  Updates
the free list with the newly allocated memory.

\param last tail of the free _block list
\param size size in bytes to request from the OS

\return returns the newly allocated _block of NULL if failed
\ brief growheap Given a requested size of memory use sbrk () to dynamically increase the data segment of the calling process . Updates the free list with the newly allocated memory . \ param last tail of the free _block list \ param size size in bytes to request from the OS \ return returns the newly allocated _block of NULL if failed
struct _block *growHeap(struct _block *last, size_t size) 
{
   struct _block *curr = (struct _block *)sbrk(0);
   struct _block *prev = (struct _block *)sbrk(sizeof(struct _block) + size);
   assert(curr == prev);
   if (curr == (struct _block *)-1) 
   {
      return NULL;
   }
   if (heapList == NULL) 
   {
      heapList = curr;
   }
   if (last) 
   {
      last->next = curr;
   }
   curr->size = size;
   curr->next = NULL;
   curr->free = false;
   curr->prev = last;
   return curr;
}
struct _block * growHeap ( struct _block * last , size_t size ) { struct _block * curr = ( struct _block * ) sbrk ( 0 ) ; struct _block * prev = ( struct _block * ) sbrk ( sizeof ( struct _block ) + size ) ; assert ( curr == prev ) ; if ( curr == ( struct _block * ) -1 ) { return NULL ; } if ( heapList == NULL ) { heapList = curr ; } if ( last ) { last -> next = curr ; } curr -> size = size ; curr -> next = NULL ; curr -> free = false ; curr -> prev = last ; return curr ; }
\brief growheap
 Given a requested size of memory, use sbrk() to dynamically
 increase the data segment of the calling process.
\ brief growheap Given a requested size of memory use sbrk () to dynamically increase the data segment of the calling process .
/* Request more space from OS */ /* OS allocation failed */ /* Update heapList if not set */ /* Attach new _block to prev _block */ /* Update _block metadata */