I have a function which expect a wchar_t**
, I am allocating it:
wchar_t * * lFilterPatterns = malloc(aNumOfFilterPatterns*sizeof(wchar_t *));
for (i = 0; i < aNumOfFilterPatterns; i++)
{
lFilterPatterns[i] = malloc(MAX_PATH_OR_CMD*sizeof(wchar_t));
}
is there a better/simpler way to make this allocation ?
edit: I would prefer to call malloc once only.
this has been proposed:
wchar_t (*lFilterPatterns)[MAX_PATH_OR_CMD] =
malloc(aNumOfFilterPatterns * sizeof * lFilterPatterns);
but then the function complains: warning C4047: 'function' :
'wchar_t * *' differs in levels of indirection from 'wchar_t (*)[1024]'
can I cast 'wchar_t (*)[1024]' into 'wchar_t * *' ?