helper: cache get_member_name()
I've been calling get_member_name() more and more often so it's worth
caching the results. That means that instead of allocating a permanent
string, I need to allocate and sname string which is not freed until the
end of the function. The callers used to be responsible for freeing the
returned string but now they must leave it alone.
Some of the callers return the string again, so sometimes I just allocate
a new string in that situation.
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>