I have written following code where I am passing a WCHAR**
reference to a function in order to get it filed inside the function. Inside the function, I am filling this 2 dimensional array. I am trying to use pass by reference to get this done.
BOOL get_file_names(WCHAR** outname)
{
WCHAR **outhandlername = NULL;
if (get_all_the_file_handelers( &outhandlername) > 0)
{
(*outname)[0] = *outhandlername[0];
}
return ret;
}
int get_all_the_file_handelers(WCHAR** outhandleName )
{
for (i = 0; i < 10; i++)
{
WCHAR *handleName = get_handle_name(handle, i);
outhandleName = (WCHAR**)realloc(outhandleName, sizeof(WCHAR)*(10 + 1));
(*outhandleName) = (WCHAR*)realloc(*outhandleName, sizeof(WCHAR)*(1024));
*outhandleName = handleName;
}
return 0;
}
But this does not seems to work, could anybody help me to understand how pass by reference works for array of WCHAR
in a case like this. When I have WHCAR**
, what is it correct to pass &WCHAR
to second function, and inside the second function how should I be assigning the values for 2 dimensional WCHAR
array
int _tmain(int argc, _TCHAR* argv[])
{
WCHAR *outhandlename=NULL;
get_file_names(&outhandlename);
DBGLOG("handler name %ls", outhandlename);
return 0;
}
BOOL process_search_file_handle( WCHAR** str)
{
*str = (WCHAR*) malloc(1024);
*str = L"TestName";
return true;
}
BOOL get_file_names(WCHAR** outname)
{
WCHAR **outhandlername = NULL;
if (get_all_the_file_handelers( &outhandlername) > 0)
{
*outname = outhandlername[0];
DBGLOG("outhandlername value %ls", outhandlername[0]);
DBGLOG("str value %ls", *outname);
}
return true;
}