current_heap += len - old_len; if (current_heap > peak_heap) peak_heap = current_heap;
memusage_size_t heap = atomic_exchange_and_add (&current_heap, len - old_len) + len - old_len; atomic_max (&peak_heap, heap);
update_data (struct header *result, size_t len, size_t old_len){  long int total_use;  if (result != NULL)    {      /* Record the information we need and mark the block using a         magic number.  */      result->length = len;      result->magic = MAGIC;    }  /* Compute current heap usage and compare it with the maximum value.  */  current_heap += len - old_len;  if (current_heap > peak_heap)    peak_heap = current_heap;  /* Compute current stack usage and compare it with the maximum value.  */#ifdef STACK_GROWS_UPWARD  current_stack = GETSP () - start_sp;#else  current_stack = start_sp - GETSP ();#endif  if (current_stack > peak_stack)    peak_stack = current_stack;  /* Add up heap and stack usage and compare it with the maximum value.  */  total_use = current_heap + current_stack;  if (total_use > peak_total)    peak_total = total_use;  /* Store the value only if we are writing to a file.  */  if (fd != -1)    {      buffer[buffer_cnt].heap = current_heap;      buffer[buffer_cnt].stack = current_stack;      GETTIME (buffer[buffer_cnt].time_low, buffer[buffer_cnt].time_high);      ++buffer_cnt;      /* Write out buffer if it is full.  */      if (buffer_cnt == buffer_size)	{	  write (fd, buffer, buffer_cnt * sizeof (struct entry));	  buffer_cnt = 0;	}    }}