void CSoundFile::FreeSample(LPVOID p) //----------------------------------- { if (p) { GlobalFreePtr(((LPSTR)p)-16); } }
/**************************************************************************** * * * Function: PlayNavigatingSound * * * * Purpose : Play system navigating sound. * * * * History : Date Reason * * 00/00/00 Created * * * ****************************************************************************/ static void PlayNavigatingSound(void) { HKEY hKey = NULL; ULONG ulBufferSize = MAX_PATH + sizeof(TCHAR); LPTSTR lpszBuffer = GlobalAllocPtr(GPTR, ulBufferSize); LPTSTR lpszSoundPath = GlobalAllocPtr(GPTR, ulBufferSize); if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("AppEvents\\Schemes\\Apps\\Explorer\\Navigating\\.Current"), 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) { if (RegQueryValueEx(hKey, NULL, 0, NULL, (LPBYTE) lpszBuffer, &ulBufferSize) == ERROR_SUCCESS) { ExpandEnvironmentStrings(lpszBuffer, lpszSoundPath, ulBufferSize); PlaySound(lpszSoundPath, NULL, SND_ASYNC | SND_NODEFAULT | SND_NOWAIT); } if(hKey) RegCloseKey(hKey); } if(lpszBuffer) GlobalFreePtr(lpszBuffer); if(lpszSoundPath) GlobalFreePtr(lpszSoundPath); }
/* ** PR_MD_free() -- exported as free() ** */ void PR_MD_free( void *ptr ) { if( _pr_callback_funcs ) { (*_pr_callback_funcs->free)( ptr ); return; } else { GlobalFreePtr( ptr ); return; } } /* end free() */
static void tap_close_adapter(LPADAPTER fd) { if (fd) { if (fd->hFile) { tap_set_status(fd, false); CloseHandle(fd->hFile); } GlobalFreePtr(fd); } }
DISKS::~DISKS() { for (int i = 0; i < nDiskCount; ++i) { GlobalFreePtr(fName[i]); fName[i] = NULL; nMount[i] = 0; Dismount(i); } }
bool CBitmapShow::InitialBitmap(int width,int height) { if((Width==width)&&(Height==height)) return true; Width=width; Height=height; if(m_lpBitmapInfo!=NULL) GlobalFreePtr(m_lpBitmapInfo); int colors=GetNumberColors(); if(colors==0) colors=256; m_lpBitmapInfo = (LPBITMAPINFO) GlobalAllocPtr(GHND,sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * colors); m_lpBitmapInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); m_lpBitmapInfo->bmiHeader.biWidth = Width; m_lpBitmapInfo->bmiHeader.biHeight = Height; m_lpBitmapInfo->bmiHeader.biCompression=GetCompressionKind(); m_lpBitmapInfo->bmiHeader.biSizeImage = 0; m_lpBitmapInfo->bmiHeader.biXPelsPerMeter = 0; m_lpBitmapInfo->bmiHeader.biYPelsPerMeter = 0; m_lpBitmapInfo->bmiHeader.biPlanes = 1; m_lpBitmapInfo->bmiHeader.biBitCount =GetBitCount(); m_lpBitmapInfo->bmiHeader.biClrUsed = 0; m_lpBitmapInfo->bmiHeader.biClrImportant = 0; ILineBytes=WIDTHBYTES(Width*GetBitCount()); m_lpBitmapInfo->bmiHeader.biSizeImage=ILineBytes*Height; for(int k=0;k<colors;k++) m_lpBitmapInfo->bmiColors[k].rgbRed=m_lpBitmapInfo->bmiColors[k].rgbGreen=m_lpBitmapInfo->bmiColors[k].rgbBlue=k; if(!CreateDIBPalette()) { if(m_lpBitmapInfo!=NULL) GlobalFreePtr(m_lpBitmapInfo); m_lpBitmapInfo=NULL; return false; } if(lpDIBBits!=NULL) GlobalFreePtr(lpDIBBits); lpDIBBits=NULL; lpDIBBits=(unsigned char*)GlobalAllocPtr(GHND,ILineBytes*Height); if(lpDIBBits==NULL) { if(m_lpBitmapInfo!=NULL) GlobalFreePtr(m_lpBitmapInfo); m_lpBitmapInfo=NULL; if(Palette!=NULL) delete Palette; Palette=NULL; return false; } return true; }
VOID PacketCloseAdapter( LPADAPTER lpAdapter ) { D(bug("Packet32: PacketCloseAdapter\n")); if(lpAdapter) { if(lpAdapter->hFile) { CloseHandle(lpAdapter->hFile); } GlobalFreePtr(lpAdapter); } }
// // ConverterCleanup // // Free anything we ever allocated // void ConverterCleanup( void ) { DWORD idx; /* if( hInFile != INVALID_HANDLE_VALUE ) { CloseHandle( hInFile ); hInFile = INVALID_HANDLE_VALUE; }*/ if( ifs.pitsTracks ) { // De-allocate all our track buffers for( idx = 0; idx < ifs.dwTrackCount; idx++ ) if( ifs.pitsTracks[idx].pTrackStart ) GlobalFreePtr( ifs.pitsTracks[idx].pTrackStart ); GlobalFreePtr( ifs.pitsTracks ); ifs.pitsTracks = NULL; } }
void AudioFormat::OnCancel() { // TODO: Add extra cleanup here if (pwfxLocal) { GlobalFreePtr(pwfxLocal); pwfxLocal = NULL; } CDialog::OnCancel(); }
void DisposeHandle (Handle handle) { memError = noErr; if (handle) { Ptr p; p = *handle; if (p) GlobalFreePtr (p); GlobalFreePtr ((Ptr)handle); } else memError = nilHandleErr; }
// This frees our instance structure, and everything within the // structure. static LONG NEAR PASCAL AVIDrawClose(PINSTINFO pi) { if (pi->hdd) { DrawDibClose(pi->hdd); } if (pi->hddb) { DisintegrateMemoryDC(pi); } GlobalFreePtr(pi); return 1; }
void aviaudioCloseDevice(void) { if (shWaveOut) { while (0 < swBuffers) { --swBuffers; waveOutUnprepareHeader(shWaveOut, salpAudioBuf[swBuffers], sizeof(WAVEHDR)); GlobalFreePtr((LPSTR) salpAudioBuf[swBuffers]); } waveOutClose(shWaveOut); shWaveOut = NULL; } }
VOID DimesPacketCloseAdapter(LPADAPTER lpAdapter) { if(!lpAdapter) { printf("PacketCloseAdapter: attempt to close a NULL adapter\n"); return; } CloseHandle(lpAdapter->hFile); SetEvent(lpAdapter->ReadEvent); CloseHandle(lpAdapter->ReadEvent); GlobalFreePtr(lpAdapter); }
BOOLEAN DimesPacketSetReadEvt(LPADAPTER AdapterObject) { DWORD BytesReturned; char EventName[100]; DWORD lastError; if (LOWORD(GetVersion()) == 4) { // retrieve the name of the shared event from the driver without the "Global\\" prefix if(DeviceIoControl(AdapterObject->hFile,pBIOCEVNAME,NULL,0,EventName,3*13*sizeof(TCHAR),&BytesReturned,NULL)==FALSE) return FALSE; EventName[BytesReturned/sizeof(TCHAR)]=0; // terminate the string } else { PCHAR name; // this tells the terminal service to retrieve the event from the global namespace // retrieve the name of the shared event from the driver with the "Global\\" prefix if(DeviceIoControl(AdapterObject->hFile,pBIOCEVNAME,NULL,0,EventName + 7,93,&BytesReturned,NULL)==FALSE) return FALSE; void* str2 = (void*)(EventName+7); PWCHAR string = (PWCHAR)str2; name = WChar2SChar(/*EventName+7*/string); name[BytesReturned/2]='\0'; sprintf(EventName,"Global\\%s",name); GlobalFreePtr(name); } JavaLog::javalogf(LEVEL_INFO,"event name :%s" , EventName); // open the shared event AdapterObject->ReadEvent=CreateEvent(NULL, TRUE, FALSE, EventName); lastError = GetLastError(); if(AdapterObject->ReadEvent==NULL || lastError!=ERROR_ALREADY_EXISTS){ printf("PacketSetReadEvt: error retrieving the event from the kernel\n"); printError(lastError); return FALSE; } else JavaLog::javalogf(LEVEL_INFO,"Read event success\n"); AdapterObject->ReadTimeOut=0; return TRUE; }
BOOL riffCopyChunk(HMMIO hmmioSrc, HMMIO hmmioDst, const LPMMCKINFO lpck) { MMCKINFO ck; HPSTR hpBuf; // // // hpBuf = (HPSTR)GlobalAllocPtr(GHND, lpck->cksize); if (!hpBuf) return (FALSE); ck.ckid = lpck->ckid; ck.cksize = lpck->cksize; if (mmioCreateChunk(hmmioDst, &ck, 0)) goto rscc_Error; if (mmioRead(hmmioSrc, hpBuf, lpck->cksize) != (LONG)lpck->cksize) goto rscc_Error; if (mmioWrite(hmmioDst, hpBuf, lpck->cksize) != (LONG)lpck->cksize) goto rscc_Error; if (mmioAscend(hmmioDst, &ck, 0)) goto rscc_Error; if (hpBuf) GlobalFreePtr(hpBuf); return (TRUE); rscc_Error: if (hpBuf) GlobalFreePtr(hpBuf); return (FALSE); } /* RIFFSupCopyChunk() */
LPVOID LoadFile(LPCTSTR szFile, DWORD * pFileLength) { LPVOID pFile; HANDLE hFile; HANDLE h; DWORD FileLength; #ifdef WIN32 hFile = CreateFile(szFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); if (hFile == INVALID_HANDLE_VALUE) return 0; FileLength = (LONG)GetFileSize(hFile, NULL); if (pFileLength) *pFileLength = FileLength ; h = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL); CloseHandle(hFile); if (h == INVALID_HANDLE_VALUE) return 0; pFile = MapViewOfFile(h, FILE_MAP_READ, 0, 0, 0); CloseHandle(h); if (pFile == NULL) return 0; #else hFile = (HANDLE)_lopen(szFile, OF_READ); if (hFile == (HANDLE)-1) return 0; FileLength = _llseek((int)hFile, 0, SEEK_END); _llseek((int)hFile, 0, SEEK_SET); pFile = GlobalAllocPtr(GHND, FileLength); if (pFile && _hread((int)hFile, pFile, FileLength) != FileLength) { GlobalFreePtr(pFile); pFile = NULL; } _lclose((int)hFile); #endif return pFile; }
PSDDriver::~PSDDriver() { // Free the row sizes if we allocated them. if (m_pSizes != NULL) { GlobalFreePtr(m_pSizes); } // Delete all the files we used. for (int nFile = 0; nFile < m_ChannelFiles.GetSize(); nFile++) { delete (ReadOnlyFile*)m_ChannelFiles.GetAt(nFile); } }
static VOID Cleanup(VOID) { PSTREAMBUF pCurr; PSTREAMBUF pNext; if (hInFile != INVALID_HANDLE_VALUE) CloseHandle(hInFile); if (hOutFile != INVALID_HANDLE_VALUE) CloseHandle(hOutFile); if (ifs.pFile) GlobalFreePtr(ifs.pFile); // faB: made pTracks static //if (ifs.pTracks) //GlobalFreePtr(ifs.pTracks); pCurr = ots.pFirst; while (pCurr) { pNext = pCurr->pNext; GlobalFreePtr(pCurr); pCurr = pNext; } }
/* void VPictureData_GDIPlus_Vector::FromVFile(VFile& inFile) { Gdiplus::Rect rect; SetDataSource(NULL,true); _DisposeMetaFile(); _SetDecoderByExtension("emf"); VString path; inFile.GetPath(path); fMetafile=new Gdiplus::Metafile(path.GetCPointer()); _InitSize(); } */ void VPictureData_GDIPlus_Vector::_FromMetaFilePict(METAFILEPICT* inMetaPict) { HENHMETAFILE henh; void* lpWinMFBits; UINT uiSizeBuf; uiSizeBuf = GetMetaFileBitsEx(inMetaPict->hMF, 0, NULL); lpWinMFBits = GlobalAllocPtr(GHND, uiSizeBuf); GetMetaFileBitsEx(inMetaPict->hMF, uiSizeBuf, (LPVOID)lpWinMFBits); henh = SetWinMetaFileBits(uiSizeBuf, (LPBYTE)lpWinMFBits, NULL, inMetaPict); GlobalFreePtr(lpWinMFBits); _FromEnhMetaFile(henh); }
CRarArchive::~CRarArchive() //------------------------- { if (UnpMemory) { delete UnpMemory; UnpMemory=NULL; } if (m_lpOutputFile) { GlobalFreePtr(m_lpOutputFile); m_lpOutputFile = NULL; } }
~win_movie_Rec() { if(bAudio) { #ifdef SND_USE_FMOD if(fmod_stream) FSOUND_Stream_Close(fmod_stream); #endif acmStreamUnprepareHeader(acmStream,&audioStreamHeader,0); acmStreamClose(acmStream,0); delete[] audioDecoded; delete[] audioEncoded; AVIStreamRelease(audioStream); } if(bDecompStarted) ICDecompressEnd(hIC); if(hIC) ICClose(hIC); if(outdata) GlobalFreePtr(outdata); if(indata) GlobalFreePtr(indata); if(stream) AVIStreamRelease(stream); if(avi) AVIFileRelease(avi); if(img) { FreeImageHandle(imgHandle); delete img; } if(handle != 0) Handle::free(HANDLE_TYPE_MOVIE,handle); }
void COXSound::CloseWaveOutDevice() // --- In: // --- Out: // --- Returns: // --- Effect: Closes the wave output device and frees associated memory. { if (m_hWaveOut != NULL) { waveOutClose(m_hWaveOut); m_hWaveOut = NULL; } if (m_lpWaveHdr != NULL) { GlobalFreePtr(m_lpWaveHdr); m_lpWaveHdr = NULL; } if (m_lpWaveData != NULL) { GlobalFreePtr(m_lpWaveData); m_lpWaveData = NULL; } }
//--------------------------------------------------------------------------- VOID PacketCloseAdapter (LPADAPTER lpAdapter) { ODS ("Packet32: PacketCloseAdapter\n"); // close the capture handle CloseHandle (lpAdapter->hFile); // close the read event CloseHandle (lpAdapter->ReadEvent); GlobalFreePtr (lpAdapter); lpAdapter = NULL; }
/* do a packet request call */ int wpcap_packet_request(void *adapter, ULONG Oid, int set, char *value, unsigned int *length) { BOOLEAN Status; ULONG IoCtlBufferLength=(sizeof(PACKET_OID_DATA) + (*length) - 1); PPACKET_OID_DATA OidData; g_assert(has_wpacket); if(p_PacketRequest == NULL) { g_warning("packet_request not available\n"); return 0; } /* get a buffer suitable for PacketRequest() */ OidData=GlobalAllocPtr(GMEM_MOVEABLE | GMEM_ZEROINIT,IoCtlBufferLength); if (OidData == NULL) { g_warning("GlobalAllocPtr failed for %u\n", IoCtlBufferLength); return 0; } OidData->Oid = Oid; OidData->Length = *length; memcpy(OidData->Data, value, *length); Status = p_PacketRequest(adapter, set, OidData); if(Status) { if(OidData->Length <= *length) { /* copy value from driver */ memcpy(value, OidData->Data, OidData->Length); *length = OidData->Length; } else { /* the driver returned a value that is longer than expected (and longer than the given buffer) */ g_warning("returned oid too long, Oid: 0x%x OidLen:%u MaxLen:%u", Oid, OidData->Length, *length); Status = FALSE; } } GlobalFreePtr (OidData); if(Status) { return 1; } else { return 0; } }
//--------------------------------------------------------------------------- String CUtilites::GetFolder(String Caption) { BROWSEINFO bi; char GDir[MAX_PATH]; char FolderName[MAX_PATH]; LPITEMIDLIST ItemID; memset(&bi, 0, sizeof(BROWSEINFO)); memset(GDir, 0, MAX_PATH); bi.hwndOwner = Application->Handle; bi.pszDisplayName = FolderName; bi.lpszTitle = Caption.c_str(); ItemID = SHBrowseForFolder(&bi); SHGetPathFromIDList(ItemID, GDir); GlobalFreePtr(ItemID); return String(GDir); }
LPMRUMENU CreateMruMenu( WORD wNbLruShowInit, WORD wNbLruMenuInit, WORD wMaxSizeLruItemInit, WORD wIdMruInit ) { LPMRUMENU lpMruMenu; lpMruMenu = ( LPMRUMENU )GlobalAllocPtr( GHND, sizeof( MRUMENU ) ); lpMruMenu->wNbItemFill = 0; lpMruMenu->wNbLruMenu = wNbLruMenuInit; lpMruMenu->wNbLruShow = wNbLruShowInit; lpMruMenu->wIdMru = wIdMruInit; lpMruMenu->wMaxSizeLruItem = wMaxSizeLruItemInit; lpMruMenu->lpMRU = ( LPSTR )GlobalAllocPtr( GHND, lpMruMenu->wNbLruMenu * ( UINT )lpMruMenu->wMaxSizeLruItem ); if( lpMruMenu->lpMRU == NULL ) { GlobalFreePtr( lpMruMenu ); lpMruMenu = NULL; } return lpMruMenu; }
/***************************************************************************** * * smfCloseFile * * This function closes an open MIDI file. * * hSmf - The handle of the open file to close. * * Returns * SMF_SUCCESS The specified file was closed. * SMF_INVALID_PARM The given handle was not valid. * * Any track handles opened from this file handle are invalid after this * call. * *****************************************************************************/ SMFRESULT FNLOCAL smfCloseFile( HSMF hSmf) { PSMF pSmf = (PSMF)hSmf; assert(pSmf != NULL); /* ** Free up handle memory */ if (NULL != pSmf->hpbImage) GlobalFreePtr(pSmf->hpbImage); LocalFree((HLOCAL)pSmf); return SMF_SUCCESS; }
void myfree( void** Hdl ) // free Memory, use Handles { if (Hdl) { LPSTR p; GlobalUnlock((LPSTR *) Hdl); p = *((LPSTR*) Hdl); //Use VirtualFree because of Win 95/98/ME memory allocation problems //See Microsfot KB article Q198959 if (p) VirtualFree(p, 0, MEM_RELEASE); GlobalFreePtr ((LPSTR) Hdl); } }
void VPictureData_EMF::FromMetaFilePict(METAFILEPICT* inMetaPict) { HENHMETAFILE henh; _ReleaseDataProvider(); _DisposeMetaFile(); void* lpWinMFBits; UINT uiSizeBuf; uiSizeBuf = GetMetaFileBitsEx(inMetaPict->hMF, 0, NULL); lpWinMFBits = GlobalAllocPtr(GHND, uiSizeBuf); GetMetaFileBitsEx(inMetaPict->hMF, uiSizeBuf, (LPVOID)lpWinMFBits); henh = SetWinMetaFileBits(uiSizeBuf, (LPBYTE)lpWinMFBits, NULL, inMetaPict); GlobalFreePtr(lpWinMFBits); FromEnhMetaFile(henh); }
//************************************************************* // // SaveMruInIni() // // Purpose: // Save MRU in a private .INI // // Parameters: // LPMRUMENU lpMruMenu - pointer on MRUMENU // LPSTR lpszSection - Points to a null-terminated string containing // the name of the section // LPSTR lpszFile - Points to a null-terminated string that names // the initialization file. // // Return: (BOOL) // TRUE - Function run successfully // FALSE - Function don't run successfully // // // Comments: // See WritePrivateProfileString API for more info on lpszSection and lpszFile // // History: Date Author Comment // 09/24/94 G. Vollant Created // //************************************************************* BOOL SaveMruInIni( LPMRUMENU lpMruMenu, LPSTR lpszSection, LPSTR lpszFile ) { LPSTR lpTxt; WORD i; lpTxt = ( LPSTR )GlobalAllocPtr( GHND, lpMruMenu->wMaxSizeLruItem + 20 ); if( lpTxt == NULL ) { return FALSE; } for( i = 0; i < lpMruMenu->wNbLruMenu; i++ ) { char szEntry[16]; wsprintf( szEntry, "File%lu", ( DWORD )i + 1 ); if( !GetMenuItem( lpMruMenu, i, FALSE, lpTxt, lpMruMenu->wMaxSizeLruItem + 10 ) ) { *lpTxt = '\0'; } WritePrivateProfileString( lpszSection, szEntry, lpTxt, lpszFile ); } GlobalFreePtr( lpTxt ); WritePrivateProfileString( NULL, NULL, NULL, lpszFile ); // flush cache return TRUE; }