Handle NewHandle ( long size ) { Handle mHand; char *p; memError = noErr; mHand = (Handle) GlobalAllocPtr (GHND, (sizeof (Handle) + signatureSize)); if (mHand) *mHand = (Ptr) GlobalAllocPtr (GHND, size); if (!mHand || !(*mHand)) { memError = memFullErr; return NULL; } // put the signature after the pointer p = (char *) mHand; p += sizeof (Handle); memcpy (p,cSig, signatureSize); return mHand; }
LPPACKET PacketAllocatePacket( LPADAPTER AdapterObject, UINT Length ) { LPPACKET lpPacket; lpPacket = (LPPACKET)GlobalAllocPtr( GMEM_MOVEABLE|GMEM_ZEROINIT, sizeof(PACKET) ); if(lpPacket==NULL) { D(bug("Packet32: PacketAllocatePacket: GlobalAlloc Failed\n")); return NULL; } lpPacket->OverLapped.hEvent = CreateEvent(NULL,FALSE,FALSE,NULL); if(!lpPacket->OverLapped.hEvent) { D(bug("Packet32: PacketAllocatePacket: CreateEvent Failed\n")); GlobalFreePtr(lpPacket); return NULL; } lpPacket->Buffer = GlobalAllocPtr(GMEM_MOVEABLE,2048); // 1514 if(!lpPacket->Buffer) { D(bug("Packet32: PacketAllocatePacket: GlobalAllocPtr Failed\n")); if(lpPacket->OverLapped.hEvent) CloseHandle(lpPacket->OverLapped.hEvent); GlobalFreePtr(lpPacket); return NULL; } lpPacket->OverLapped.Offset = 0; lpPacket->OverLapped.OffsetHigh = 0; lpPacket->Length = Length; lpPacket->BytesReceived = 0; lpPacket->bIoComplete = FALSE; lpPacket->free = TRUE; return lpPacket; }
int PASCAL WinMain( HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow ) { TIMERINFO ti; DWORD beforeTickCountFast, afterTickCountFast; DWORD beforeTickCountSlow, afterTickCountSlow, i; BYTE __huge *hpvSrc; BYTE __huge *hpvDest; char szBuffer[256]; hpvSrc = GlobalAllocPtr( GMEM_MOVEABLE, BLOCK_SIZE ); hpvDest = GlobalAllocPtr( GMEM_MOVEABLE, BLOCK_SIZE ); if ( !hpvSrc || !hpvDest ) { MessageBox(0, "Couldn't allocate src/dest segs", 0, MB_OK); return 0; } // Call the 32 bit function once without timing it to let it switch // to a 32 bit segment. memcpy32( SELECTOROF(hpvDest), OFFSETOF(hpvDest), SELECTOROF(hpvSrc), OFFSETOF(hpvSrc), BLOCK_SIZE ); ti.dwSize = sizeof(ti); TimerCount(&ti); beforeTickCountFast = ti.dwmsThisVM; // Now call the 32 bit function again, this time timing it. memcpy32( SELECTOROF(hpvDest), OFFSETOF(hpvDest), SELECTOROF(hpvSrc), OFFSETOF(hpvSrc), BLOCK_SIZE ); TimerCount( &ti ); afterTickCountFast = ti.dwmsThisVM; TimerCount(&ti); beforeTickCountSlow = ti.dwmsThisVM; for ( i=0; i < BLOCK_SIZE; i++) *hpvDest++ = *hpvSrc++; TimerCount( &ti ); afterTickCountSlow = ti.dwmsThisVM; wsprintf(szBuffer, "32 bit move: %lu milliseconds\r\n" "huge pointer move: %lu milliseconds", afterTickCountFast - beforeTickCountFast, afterTickCountSlow - beforeTickCountSlow); MessageBox( 0, szBuffer, "MIX1632 - Matt Pietrek 1994", MB_OK ); return 0; }
void LuminanceChrominance(SImageRGB ImageRGB, SImage Y, SImage C0, SImage C1) { rgb RGB; long l = 0; int lum; long i,j; unsigned char * ImY = (unsigned char *) Y.Image; unsigned char * ImC0 = (unsigned char *) C0.Image; unsigned char * ImC1 = (unsigned char *) C1.Image; int * Chromi0 = (int * ) GlobalAllocPtr(GMEM_FIXED | GMEM_ZEROINIT,(ImageRGB.Lmax-ImageRGB.Lmin+1)*(ImageRGB.Hmax-ImageRGB.Hmin+1)*sizeof(int)); int * Chromi1 = (int *) GlobalAllocPtr(GMEM_FIXED | GMEM_ZEROINIT,(ImageRGB.Lmax-ImageRGB.Lmin+1)*(ImageRGB.Hmax-ImageRGB.Hmin+1)*sizeof(int)); int MaxRouge=-255,MaxBleu=-255; int MinRouge=255,MinBleu=255; for (j= ImageRGB.Hmin;j<=ImageRGB.Hmax;j++) { for (i=ImageRGB.Lmin;i<=ImageRGB.Lmax;i++) { RGB = ImageRGB.Image[j*ImageRGB.Larg+i]; lum = (int)(0.3*RGB.r + 0.59*RGB.g + 0.11*RGB.b); ((unsigned char * )ImY)[l] = (unsigned char) lum; Chromi0[l] = (int)RGB.r-lum; Chromi1[l] = (int)RGB.b-lum; if (Chromi0[l] > MaxRouge) MaxRouge =Chromi0[l]; if (Chromi1[l] > MaxBleu) MaxBleu = Chromi1[l] ; if (Chromi0[l] < MinRouge) MinRouge = Chromi0[l] ; if (Chromi1[l] < MinBleu) MinBleu = Chromi1[l] ; l++; } } l = 0; // normalisation des chrominances int normR,normB,norm; if (MaxRouge==MinRouge) normR= 1; else normR = (MaxRouge-MinRouge)/255; if (MaxBleu==MinBleu) normB= 1; else normB = (MaxBleu-MinBleu)/255; if (normR>normB) norm = normR; else norm = normB; for (j= ImageRGB.Hmin;j<=ImageRGB.Hmax;j++) { for (i=ImageRGB.Lmin;i<=ImageRGB.Lmax;i++) { RGB = ImageRGB.Image[j*ImageRGB.Larg+i]; ((unsigned char * )ImC0)[l] = (unsigned char) (Chromi0[l]-MinRouge)/norm; ((unsigned char * )ImC1)[l] = (unsigned char) (Chromi1[l] -MinBleu)/norm; l++; } } GlobalFreePtr(Chromi0); GlobalFreePtr(Chromi1); }
void CDib::LoadStream(IStream *pStr) { BITMAPFILEHEADER bitmapFileHeader; ULONG ReadSize = 0; HRESULT hr = S_OK; hr = pStr->Read((void*)&bitmapFileHeader,sizeof(BITMAPFILEHEADER),&ReadSize); if (SUCCEEDED(hr)&&(bitmapFileHeader.bfType == 0x4d42)) { DWORD fileLength = bitmapFileHeader.bfSize; DWORD size = fileLength - sizeof(BITMAPFILEHEADER); BYTE* pDib = (BYTE*)GlobalAllocPtr(GMEM_MOVEABLE, size); hr = pStr->Read((void*)pDib, size,&ReadSize); if(SUCCEEDED(hr)) { m_pBitmapInfo = (BITMAPINFO*)pDib; m_pBitmapInfoHeader = (BITMAPINFOHEADER*) pDib; m_pRGB = (RGBQUAD*)(pDib + m_pBitmapInfoHeader->biSize); int m_numberOfColors = GetNumberOfColors(); if (m_pBitmapInfoHeader->biClrUsed == 0) m_pBitmapInfoHeader->biClrUsed = m_numberOfColors; DWORD colorTableSize = m_numberOfColors * sizeof(RGBQUAD); m_pData = pDib + m_pBitmapInfoHeader->biSize + colorTableSize; if (m_pRGB == (RGBQUAD*)m_pData) // No color table m_pRGB = NULL; m_pBitmapInfoHeader->biSizeImage = GetSize(); m_valid = TRUE; return ; } } m_valid = FALSE; #ifdef _DEVELOVER_VERSION_L1 AfxMessageBox(_T("This isn't a bitmap file in Stream!")); #endif }
void CDib::LoadFile(const char* dibFileName) { strcpy(m_fileName,dibFileName); CFile dibFile(m_fileName, CFile::modeRead); dibFile.Read((void*)&bitmapFileHeader,sizeof(BITMAPFILEHEADER)); if (bitmapFileHeader.bfType == 0x4d42) { DWORD fileLength = dibFile.GetLength(); size = fileLength -sizeof(BITMAPFILEHEADER); pDib =(BYTE*)GlobalAllocPtr(GMEM_MOVEABLE, size); dibFile.Read((void*)pDib, size); dibFile.Close(); m_pBitmapInfo = (BITMAPINFO*) pDib; m_pBitmapInfoHeader = (BITMAPINFOHEADER*) pDib; m_pRGB = (RGBQUAD*)(pDib + m_pBitmapInfoHeader->biSize); int m_numberOfColors = GetNumberOfColors(); if (m_pBitmapInfoHeader->biClrUsed == 0) m_pBitmapInfoHeader->biClrUsed = m_numberOfColors; DWORD colorTableSize = m_numberOfColors * sizeof(RGBQUAD); m_pData = pDib + m_pBitmapInfoHeader->biSize + colorTableSize; if (m_pRGB == (RGBQUAD*)m_pData) // No color table m_pRGB = NULL; m_pBitmapInfoHeader->biSizeImage = GetSize(); m_valid = TRUE; } else { m_valid = FALSE; AfxMessageBox("This isn't a bitmap file!"); } }
CModelFrame::CModelFrame() { m_Limited=600; m_iDem=512; m_bArroy=new BYTE[m_iDem]; Pallete=(LPBITMAPINFO)GlobalAllocPtr(GHND, (sizeof (BITMAPINFO)+ (sizeof (RGBQUAD)*255 ))); Pallete->bmiHeader.biSize = 40; Pallete->bmiHeader.biWidth = m_iDem; Pallete->bmiHeader.biHeight = m_iDem; Pallete->bmiHeader.biPlanes = 1; Pallete->bmiHeader.biBitCount = 8; Pallete->bmiHeader.biCompression=BI_RGB; Pallete->bmiHeader.biSizeImage = 0; Pallete->bmiHeader.biXPelsPerMeter = 0; Pallete->bmiHeader.biYPelsPerMeter = 0; Pallete->bmiHeader.biClrUsed = 0; Pallete->bmiHeader.biClrImportant = 0; for(int i=0;i<256;i++) { Pallete->bmiColors[i].rgbRed = Pallete->bmiColors[i].rgbGreen = Pallete->bmiColors[i].rgbBlue = i; } GetModel(); }
/////////////////////////////////////// // member function CreateBITMAPINFO /////////////////////////////////////// BOOL CDib::CreateBITMAPINFO() { UINT biSize; // determine the amount of memory needed to hold BITMAPINFO biSize = GetBITMAPINFOSize(); // Allocate the BITMAPINFO data structure if (lpbinfo != NULL) GlobalFreePtr(lpbinfo); lpbinfo = (LPBITMAPINFO) GlobalAllocPtr(GMEM_MOVEABLE,biSize); if (lpbinfo == NULL) { SetCDibState(FAIL_LPBI_ALLOC); return FALSE; } // initialize the values to ZERO memset(lpbinfo, 0, biSize); return TRUE; }
//--------------------------------------------------------------------------- BOOLEAN PacketGetNetType (LPADAPTER AdapterObject,NetType *type) { BOOLEAN Status; ULONG IoCtlBufferLength = (sizeof (PACKET_OID_DATA) + sizeof (ULONG) - 1); PPACKET_OID_DATA OidData; ODS ("Packet32: PacketSetFilter\n"); _ASSERTE (AdapterObject != NULL); OidData = GlobalAllocPtr ( GMEM_MOVEABLE | GMEM_ZEROINIT, IoCtlBufferLength ); if (OidData == NULL) { return FALSE; } //get the link-layer type OidData->Oid = OID_GEN_MEDIA_IN_USE; OidData->Length = sizeof (ULONG); Status = PacketRequest(AdapterObject,FALSE,OidData); if(Status==FALSE)return FALSE; type->LinkType=*((UINT*)OidData->Data); //get the link-layer speed OidData->Oid = OID_GEN_LINK_SPEED; OidData->Length = sizeof (ULONG); Status = PacketRequest(AdapterObject,FALSE,OidData); type->LinkSpeed=*((UINT*)OidData->Data)*100; GlobalFreePtr (OidData); return Status; }
// This basically allocates our "instance info" (that struct defined // at the beginning of this file). static LONG NEAR PASCAL AVIDrawOpen(ICOPEN FAR * icopen) { PINSTINFO pinst; if (icopen->fccType != streamtypeVIDEO) { return 0; } if (icopen->dwFlags == ICMODE_COMPRESS) { return 0; } if (icopen->dwFlags == ICMODE_DECOMPRESS) { return 0; } pinst = (PINSTINFO)GlobalAllocPtr(GHND, sizeof(INSTINFO)); if (!pinst) { icopen->dwError = ICERR_MEMORY; return NULL; } pinst->hdd = DrawDibOpen(); pinst->hddb = NULL; icopen->dwError = ICERR_OK; return (LONG) pinst; }
signed char* CSoundFile::AllocateSample(UINT nbytes) //------------------------------------------- { signed char * p = (signed char *)GlobalAllocPtr(GHND, (nbytes+39) & ~7); if (p) p += 16; return p; }
LPADAPTER PacketOpenAdapter( LPCTSTR AdapterName, int16 mode ) { LPADAPTER lpAdapter; BOOLEAN Result = TRUE; D(bug("Packet32: PacketOpenAdapter\n")); // May fail if user is not an Administrator. StartPacketDriver( TEXT("B2ether") ); lpAdapter = (LPADAPTER)GlobalAllocPtr( GMEM_MOVEABLE|GMEM_ZEROINIT, sizeof(ADAPTER) ); if (lpAdapter==NULL) { D(bug("Packet32: PacketOpenAdapter GlobalAlloc Failed\n")); return NULL; } TCHAR device_name[256]; _sntprintf(lpAdapter->SymbolicLink, lengthof(lpAdapter->SymbolicLink), TEXT("\\\\.\\B2ether_%s"), AdapterName ); _sntprintf(device_name, lengthof(device_name), TEXT("\\Device\\B2ether_%s"), AdapterName ); // Work around one subtle NT4 bug. DefineDosDevice( DDD_REMOVE_DEFINITION, &lpAdapter->SymbolicLink[4], NULL ); DefineDosDevice( DDD_RAW_TARGET_PATH, &lpAdapter->SymbolicLink[4], device_name ); packet_filter = NDIS_PACKET_TYPE_DIRECTED | NDIS_PACKET_TYPE_MULTICAST | NDIS_PACKET_TYPE_BROADCAST; if(mode == ETHER_MULTICAST_ALL) packet_filter |= NDIS_PACKET_TYPE_ALL_MULTICAST; if(mode == ETHER_MULTICAST_PROMISCUOUS) packet_filter |= NDIS_PACKET_TYPE_PROMISCUOUS; if (Result) { lpAdapter->hFile = CreateFile(lpAdapter->SymbolicLink, GENERIC_WRITE | GENERIC_READ, 0, NULL, // (os == VER_PLATFORM_WIN32_NT) ? CREATE_ALWAYS : OPEN_EXISTING, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0 ); if (lpAdapter->hFile != INVALID_HANDLE_VALUE) { if(*AdapterName && _tcscmp(AdapterName,TEXT("<None>")) != 0) { PacketSetFilter( lpAdapter, packet_filter ); } return lpAdapter; } } D(bug("Packet32: PacketOpenAdapter Could not open adapter\n")); GlobalFreePtr( lpAdapter ); return NULL; }
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() */
static LPOLDGLOBALS NewGlobal(HWND hWnd) { LPOLDGLOBALS lp=(LPOLDGLOBALS)GlobalAllocPtr(GHND, sizeof(OLD_GLOBALS)); if (lp) { lp->hWnd=hWnd; lp->lpfnOldFarProc=NULL; lp->pNext=NULL; if (!lpFirstOldGlobals) { lpFirstOldGlobals=lp; } else { LPOLDGLOBALS lp2; for (lp2=lpFirstOldGlobals;lp2;lp2=lp2->pNext) { if (!lp2->pNext) { lp2->pNext=lp; break; } } } } return lp; }
//************************************************************* // // PlaceMenuMRUItem() // // Purpose: // Add MRU at the end of a menu // // Parameters: // LPMRUMENU lpMruMenu - pointer on MRUMENU // HMENU hMenu - Handle of menu where MRU must be added // UINT uiItem - Item of menu entry where MRU must be added // // Return: void // // // Comments: // Used MRU is modified, for refresh the File menu // // History: Date Author Comment // 09/24/94 G. Vollant Created // //************************************************************* void PlaceMenuMRUItem( LPMRUMENU lpMruMenu, HMENU hMenu, UINT uiItem ) { int i; WORD wNbShow; if ( lpMruMenu == NULL ) return; // remove old MRU in menu for ( i = 0; i <= ( int )( lpMruMenu->wNbLruMenu ); i++ ) RemoveMenu( hMenu, i + lpMruMenu->wIdMru, MF_BYCOMMAND ); if ( lpMruMenu->wNbItemFill == 0 ) return; // If they are item, insert a separator before the files InsertMenu( hMenu, uiItem, MF_SEPARATOR, lpMruMenu->wIdMru, NULL ); wNbShow = min( lpMruMenu->wNbItemFill, lpMruMenu->wNbLruShow ); for ( i = ( int )wNbShow - 1; i >= 0; i-- ) { LPSTR lpTxt; if ( lpTxt = ( LPSTR )GlobalAllocPtr( GHND, lpMruMenu->wMaxSizeLruItem + 20 ) ) { wsprintf( lpTxt, "&%lu %s", ( DWORD )( i + 1 ), lpMruMenu->lpMRU + ( lpMruMenu->wMaxSizeLruItem * ( UINT )i ) ); InsertMenu( hMenu, ( ( ( WORD )i ) != ( wNbShow - 1 ) ) ? ( lpMruMenu->wIdMru + i + 2 ) : lpMruMenu->wIdMru, MF_STRING, lpMruMenu->wIdMru + i + 1, lpTxt ); GlobalFreePtr( lpTxt ); } } }
//************************************************************* // // SaveMruInReg() // // Purpose: // Save MRU in the registry // // Parameters: // LPMRUMENU lpMruMenu - pointer on MRUMENU // LPSTR lpszKey - Points to a null-terminated string // specifying the name of a key that // this function opens or creates. // // Return: (BOOL) // TRUE - Function run successfully // FALSE - Function don't run successfully // // // Comments: // Win32 function designed for Windows NT and Windows 95 // See RegCreateKeyEx API for more info on lpszKey // // History: Date Author Comment // 09/24/94 G. Vollant Created // //************************************************************* BOOL SaveMruInReg( LPMRUMENU lpMruMenu, LPSTR lpszKey ) { LPSTR lpTxt; WORD i; HKEY hCurKey; DWORD dwDisp; lpTxt = ( LPSTR )GlobalAllocPtr( GHND, lpMruMenu->wMaxSizeLruItem + 20 ); if ( lpTxt == NULL ) return FALSE; RegCreateKeyEx( HKEY_CURRENT_USER, lpszKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hCurKey, &dwDisp ); 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'; RegSetValueEx( hCurKey, szEntry, 0, REG_SZ, ( unsigned char* )lpTxt, lstrlen( lpTxt ) ); } RegCloseKey( hCurKey ); GlobalFreePtr( lpTxt ); return TRUE; }
//************************************************************* // // LoadMruInReg() // // Purpose: // Load MRU from the registry // // Parameters: // LPMRUMENU lpMruMenu - pointer on MRUMENU // LPSTR lpszKey - Points to a null-terminated string // specifying the name of a key that // this function opens or creates. // // Return: (BOOL) // TRUE - Function run successfully // FALSE - Function don't run successfully // // // Comments: // Win32 function designed for Windows NT and Windows 95 // See RegOpenKeyEx API for more info on lpszKey // // History: Date Author Comment // 09/24/94 G. Vollant Created // //************************************************************* BOOL LoadMruInReg( LPMRUMENU lpMruMenu, LPSTR lpszKey ) { LPSTR lpTxt; WORD i; HKEY hCurKey; DWORD dwType; lpTxt = ( LPSTR )GlobalAllocPtr( GHND, lpMruMenu->wMaxSizeLruItem + 20 ); if ( lpTxt == NULL ) return FALSE; RegOpenKeyEx( HKEY_CURRENT_USER, lpszKey, 0, KEY_READ, &hCurKey ); for ( i = 0; i < lpMruMenu->wNbLruMenu; i++ ) { char szEntry[16]; DWORD dwSizeBuf; wsprintf( szEntry, "File%lu", ( DWORD )i + 1 ); *lpTxt = '\0'; dwSizeBuf = lpMruMenu->wMaxSizeLruItem + 10; RegQueryValueEx( hCurKey, szEntry, NULL, &dwType, ( LPBYTE )lpTxt, &dwSizeBuf ); *( lpTxt + dwSizeBuf ) = '\0'; if ( *lpTxt == '\0' ) break; SetMenuItem( lpMruMenu, i, lpTxt ); } RegCloseKey( hCurKey ); GlobalFreePtr( lpTxt ); return TRUE; }
//--------------------------------------------------------------------------- BOOLEAN PacketSetMaxLookaheadsize (LPADAPTER AdapterObject) { BOOLEAN Status; ULONG IoCtlBufferLength = (sizeof (PACKET_OID_DATA) + sizeof (ULONG) - 1); PPACKET_OID_DATA OidData; ODS ("Packet32: PacketSetFilter\n"); _ASSERTE (AdapterObject != NULL); OidData = GlobalAllocPtr ( GMEM_MOVEABLE | GMEM_ZEROINIT, IoCtlBufferLength ); if (OidData == NULL) { return FALSE; } //set the size of the lookahead buffer to the maximum available by the the NIC driver OidData->Oid=OID_GEN_MAXIMUM_LOOKAHEAD; OidData->Length=sizeof(ULONG); Status=PacketRequest(AdapterObject,FALSE,OidData); OidData->Oid=OID_GEN_CURRENT_LOOKAHEAD; Status=PacketRequest(AdapterObject,TRUE,OidData); GlobalFreePtr(OidData); return Status; }
//--------------------------------------------------------------------------- BOOLEAN PacketSetHwFilter (LPADAPTER AdapterObject, ULONG Filter) { BOOLEAN Status; ULONG IoCtlBufferLength = (sizeof (PACKET_OID_DATA) + sizeof (ULONG) - 1); PPACKET_OID_DATA OidData; ODS ("Packet32: PacketSetFilter\n"); _ASSERTE (AdapterObject != NULL); OidData = GlobalAllocPtr ( GMEM_MOVEABLE | GMEM_ZEROINIT, IoCtlBufferLength ); if (OidData == NULL) { return FALSE; } OidData->Oid = OID_GEN_CURRENT_PACKET_FILTER; OidData->Length = sizeof (ULONG); *((PULONG) OidData->Data) = Filter; Status = PacketRequest ( AdapterObject, TRUE, OidData ); GlobalFreePtr (OidData); return Status; }
//--------------------------------------------------------------------------- LPPACKET PacketAllocatePacket (void) { LPPACKET lpPacket; lpPacket = (LPPACKET) GlobalAllocPtr ( GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof (PACKET)); if (lpPacket == NULL) { ODS ("Packet32: PacketAllocatePacket: GlobalAlloc Failed\n"); return NULL; } lpPacket->OverLapped.hEvent = CreateEvent (NULL, FALSE, FALSE, NULL); if (lpPacket->OverLapped.hEvent == NULL) { ODS ("Packet32: PacketAllocatePacket: CreateEvent Failed\n"); GlobalFreePtr (lpPacket); return NULL; } lpPacket->Buffer=NULL; lpPacket->Length=0; lpPacket->ulBytesReceived = 0; lpPacket->bIoComplete = FALSE; return lpPacket; }
void CSpectrumFrame::CreatePallete() { Pallete=(LPBITMAPINFO)GlobalAllocPtr(GHND, (sizeof (BITMAPINFO)+ (sizeof (RGBQUAD)*255 ))); Pallete->bmiHeader.biSize = 40; Pallete->bmiHeader.biWidth = m_iDem; Pallete->bmiHeader.biHeight = m_iDem; Pallete->bmiHeader.biPlanes = 1; Pallete->bmiHeader.biBitCount = 8; Pallete->bmiHeader.biCompression=BI_RGB; Pallete->bmiHeader.biSizeImage = 0; Pallete->bmiHeader.biXPelsPerMeter = 0; Pallete->bmiHeader.biYPelsPerMeter = 0; Pallete->bmiHeader.biClrUsed = 0; Pallete->bmiHeader.biClrImportant = 0; for(int i=0;i<256;i++) { Pallete->bmiColors[i].rgbRed = Pallete->bmiColors[i].rgbGreen = Pallete->bmiColors[i].rgbBlue = i; } }
void AllocLocalCompressFormat() { if (pwfxLocal) { //Do nothing....already allocated } else { MMRESULT mmresult = acmMetrics(NULL, ACM_METRIC_MAX_SIZE_FORMAT, &cbwfxLocal); if (MMSYSERR_NOERROR != mmresult) { CString msgstr; msgstr.Format("Metrics failed mmresult=%u!", mmresult); ::MessageBox(NULL,msgstr,"Note", MB_OK | MB_ICONEXCLAMATION); return ; } if (cbwfxLocal < cbwfx) cbwfxLocal = cbwfx; pwfxLocal = (LPWAVEFORMATEX)GlobalAllocPtr(GHND, cbwfxLocal); if (NULL == pwfxLocal) { CString msgstr; msgstr.Format("GlobalAllocPtr(%lu) failed!", cbwfxLocal); ::MessageBox(NULL,msgstr,"Note", MB_OK | MB_ICONEXCLAMATION); return ; } } }
/* ** PR_MD_malloc() -- exported as malloc() ** */ void *PR_MD_malloc( size_t size ) { if( _pr_callback_funcs ) { return (*_pr_callback_funcs->malloc)( size ); } else { return GlobalAllocPtr(GPTR, (DWORD)size); } } /* end malloc() */
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; }
/***** * Retrieve all items from the file listbox in the main window. * This routine discards any preloaded list of files. * As a consequence of that, it also discards any flowgraph generated from * that filelist. * * Returns 0 if there are no files else returns 1. *****/ static int get_files_to_scan(HWND hDlg) { int i; char szBuf[MAXPATHLEN]; HWND hwndList = GetDlgItem(hDlg, IDC_MAIN_LISTBOX); if(num_files != 0 && !file_sel_changed) return(1); /* clear previous list */ destroy_filelist(); /* get no of items in the list */ num_files = (int)SendMessage(hwndList, LB_GETCOUNT, 0, 0L); /* return if no files in list */ if(num_files == 0) return(0); /* allocate memory for this list */ file_list = (char**)GlobalAllocPtr(GPTR, (num_files+1)*sizeof(char*)); if(file_list == NULL) { ErrHandler(hDlg, R_ERROR, RB_OK1, "Out of memory: Failed to " "allocate %i bytes for filelist", num_files*sizeof(char*)); exit(4); } /* get the items in the list */ for(i = 0; i < num_files; i++) { SendMessage(hwndList, LB_GETTEXT, i, (LONG)(LPSTR)szBuf); file_list[i]=(char*)GlobalAllocPtr(GPTR, (strlen(szBuf)+1)*sizeof(char)); if(file_list[i] == NULL) { ErrHandler(hDlg, R_ERROR, RB_OK1, "Out of memory: " "Failed to allocate %i bytes for file %i", (strlen(szBuf)+1)*sizeof(char), szBuf); exit(4); } strcpy(file_list[i], szBuf); } file_sel_changed = 0; return(1); }
CBitArray::CBitArray(int nBitsMin, int nBitsMax) // minimum is inclusive, maximum is exclusive { m_nMin = nBitsMin; m_nBits = nBitsMax - nBitsMin; m_cElemsPerRow = (m_nBits - 1) / (8 * sizeof (*m_pargBits)) + 1; m_pargBits = (unsigned int *) GlobalAllocPtr(GMEM_MOVEABLE | GMEM_ZEROINIT, m_cElemsPerRow * sizeof (*m_pargBits) * m_nBits); }
/**************************************************************************** * * * 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); }
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; }
bool DISKS::AddDisk(const char* szFileName) { if (nDiskCount >= N) return false; fName[nDiskCount] = (char*)GlobalAllocPtr(GPTR, strlen(szFileName) + 1); if (fName[nDiskCount] == INVALID_HANDLE_VALUE || fName[nDiskCount] == NULL) return false; strcpy(fName[nDiskCount], szFileName); nDiskCount++; return true; }
LPPACKET DimesPacketAllocatePacket(void) { LPPACKET lpPacket; lpPacket=(LPPACKET)GlobalAllocPtr(GMEM_MOVEABLE | GMEM_ZEROINIT,sizeof(PACKET)); if (lpPacket==NULL) { ODS("PacketAllocatePacket: GlobalAlloc Failed\n"); return NULL; } return lpPacket; }