Finding out the Total/Used/Free Memory : Please advice - Thanks

Hi

Based on the previous Posts - I could able to sketch out these three functions. Please advice, if this is the correct way

Thanks in advance.

Regards,

nt get_FreeMemory() 
{
  int free_memory = 0;

  if ((int)__brkval == 0) {
    free_memory = ((int)&free_memory) - ((int)&__heap_start);
  } else {
    free_memory = ((int)&free_memory) - ((int)__brkval);
    free_memory += freeListSize();
  }
  return free_memory;
}

int get_UsedMemory() 
{
  int used_memory = 0;

  if ((int)__brkval == 0) {
    used_memory = ((int)&__heap_start);
  } else {
    used_memory = ((int)__brkval);
    used_memory -= freeListSize();
  }
  return used_memory;
}

There isn't a memory controller to track how memory is being used, so getting an exact number is likely impossible. Consider those functions as estimates, not absolutes.

I could able to sketch out these three functions.

1) get_FreeMemory() 2) get_UsedMemory() 3) ?

Use either _ between words or camel case. The mix sucks.