How can the 'size' of a process shown by 'top', be read programatically in C on SunOS?

I'm fixing a memory leak in a large (20,000 lines) C program on Solaris.