size += strlen(joined + size); would cut this down to one call to strlen().