In zq_strings.cpp we have:
Why shouldn't I call this function? It is being called from void refresh in zquest.cpp, should we refactor that?Code:// Don't actually use this to strip spaces. char *strip_extra_spaces(char *string)
In zq_strings.cpp we have:
Why shouldn't I call this function? It is being called from void refresh in zquest.cpp, should we refactor that?Code:// Don't actually use this to strip spaces. char *strip_extra_spaces(char *string)
One problem is that strip_extra_spaces does not check the return value of malloc.
strlen is called many times in loops as well, no need to keep doing that if the length hasn't changed.
Note that there is an overload of strip_extra_spaces taking a std::string&
The char* overload is called by MsgString in zq_strings.cpp, which allocates a 71 character array on the heap to pass to strip_extra_spaces. It's probably fine to allocate that on the stack instead.
There are currently 1 users browsing this thread. (0 members and 1 guests)