Functions to handle dynamically allocated 2D character arrays in C