in reply to Re^4: odd line in windows
in thread odd line in windows

You save an alloc and free that way

Yes - I think that's a better approach.
(However, specifying a return type of char * and then returning an SV * is something that doesn't work well for me ;-)
I find the following works as expected (without any need to dynamically allocate/free memory) , and doesn't throw any warnings:
SV * get_proc_name( int processID ) { char szProcessName[MAX_PATH] = {0}; HANDLE hProcess = OpenProcess ( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processID ); if (NULL != hProcess ) { HMODULE hMod; DWORD cbNeeded; if ( EnumProcessModules( hProcess, &hMod, sizeof(hMod), &cbNee +ded) ) { GetModuleBaseName( hProcess, hMod, szProcessName, MAX_PATH + - 1); } else { szProcessName[0] = '#'; szProcessName[1] = 0; } } else { szProcessName[0] = '*'; szProcessName[1] = 0; } CloseHandle( hProcess ); return newSVpv(szProcessName, 0); }
Cheers,
Rob