we have a data structure
struct MyData
{
int length ;
char package[MAX_SIZE];
};
where MAX_SIZE is a fixed value . Now we want to change it so as to support "unlimited" package length greater than MAX_SIZE . one of the proposed solution is to replace the static array with a pointer and then dynamically allocating the size as we require For EX
struct MyData
{
int length ;
char* package;
};
and then
package = (char*)malloc(SOME_RUNTIME_SIZE) ;
Now my question is that is this the most efficient way to cater to the requirement OR is there any other method .. maybe using STL data structures like growable arrays etc etc . we want a solution where most of the code that works for the static char array should work for the new structure too ..