bool CBitmap::Load(std::string const& filename, unsigned char defaultAlpha) { #ifndef BITMAP_NO_OPENGL ScopedTimer timer("Textures::CBitmap::Load"); #endif bool noAlpha = true; delete[] mem; mem = NULL; #ifndef BITMAP_NO_OPENGL textype = GL_TEXTURE_2D; #endif // !BITMAP_NO_OPENGL if (filename.find(".dds") != std::string::npos) { bool status = false; #ifndef BITMAP_NO_OPENGL type = BitmapTypeDDS; xsize = 0; ysize = 0; channels = 0; ddsimage = new nv_dds::CDDSImage(); status = ddsimage->load(filename); if (status) { xsize = ddsimage->get_width(); ysize = ddsimage->get_height(); channels = ddsimage->get_components(); switch (ddsimage->get_type()) { case nv_dds::TextureFlat : textype = GL_TEXTURE_2D; break; case nv_dds::Texture3D : textype = GL_TEXTURE_3D; break; case nv_dds::TextureCubemap : textype = GL_TEXTURE_CUBE_MAP; break; case nv_dds::TextureNone : default : break; } } #endif // !BITMAP_NO_OPENGL return status; } type = BitmapTypeStandardRGBA; channels = 4; CFileHandler file(filename); if (file.FileExists() == false) { Alloc(1, 1); return false; } unsigned char* buffer = new unsigned char[file.FileSize() + 2]; file.Read(buffer, file.FileSize()); boost::mutex::scoped_lock lck(devilMutex); ilOriginFunc(IL_ORIGIN_UPPER_LEFT); ilEnable(IL_ORIGIN_SET); ILuint ImageName = 0; ilGenImages(1, &ImageName); ilBindImage(ImageName); const bool success = !!ilLoadL(IL_TYPE_UNKNOWN, buffer, file.FileSize()); ilDisable(IL_ORIGIN_SET); delete[] buffer; if (success == false) { xsize = 1; ysize = 1; mem = new unsigned char[4]; mem[0] = 255; // Red allows us to easily see textures that failed to load mem[1] = 0; mem[2] = 0; mem[3] = 255; // Non Transparent return false; } noAlpha = (ilGetInteger(IL_IMAGE_BYTES_PER_PIXEL) != 4); ilConvertImage(IL_RGBA, IL_UNSIGNED_BYTE); xsize = ilGetInteger(IL_IMAGE_WIDTH); ysize = ilGetInteger(IL_IMAGE_HEIGHT); mem = new unsigned char[xsize * ysize * 4]; //ilCopyPixels(0, 0, 0, xsize, ysize, 0, IL_RGBA, IL_UNSIGNED_BYTE, mem); memcpy(mem, ilGetData(), xsize * ysize * 4); ilDeleteImages(1, &ImageName); if (noAlpha) { for (int y=0; y < ysize; ++y) { for (int x=0; x < xsize; ++x) { mem[((y*xsize+x) * 4) + 3] = defaultAlpha; } } } return true; }
csRef<iDocumentNode> csXmlReadDocument::GetRoot () { return csPtr<iDocumentNode> (Alloc (root, false)); }
/*static*/ bool ReflectionInfo::WriteDefinitions() { uint32_t numProblems = 0; const ReflectionInfo * ri = s_FirstReflectionInfo; for ( ; ri != nullptr; ri = ri->m_Next ) { // ignore abstract classes if ( ri->IsAbstract() ) { continue; } // Serialize a default instance to a MemoryStream MemoryStream ms; { // Create and serialize default instance if ( ri->IsObject() ) { RefObject * object = ri->CreateObject(); { TextWriter tw( ms ); tw.Write( object ); } FDELETE( object ); } else { ASSERT( ri->IsStruct() ) Struct * str = ri->CreateStruct(); { TextWriter tw( ms ); tw.Write( str, ri ); } FDELETE( str ); } } AStackString<> fileName; fileName.Format( "..\\Data\\Reflection\\.Definitions\\%s.definition", ri->GetTypeName() ); // avoid writing file if not changed // Try to open existing file FileStream f; if ( f.Open( fileName.Get(), FileStream::READ_ONLY ) ) { // read content const uint64_t fileSize = f.GetFileSize(); if ( fileSize == ms.GetSize() ) { AutoPtr< char > mem( (char *)Alloc( (size_t)fileSize ) ); if ( f.Read( mem.Get(), (size_t)fileSize ) == fileSize ) { if ( memcmp( mem.Get(), ms.GetData(), (size_t)fileSize ) == 0 ) { continue; // definition has not changed } } } f.Close(); } // Definition changed - try to save it int result = 0; AutoPtr< char > memOut; AutoPtr< char > memErr; uint32_t memOutSize; uint32_t memErrSize; // existing definition? if ( FileIO::FileExists( fileName.Get() ) ) { // existing - need to open for edit? if ( FileIO::GetReadOnly( fileName ) ) { AStackString<> args( "edit " ); args += fileName; Process p; if ( p.Spawn( "p4", args.Get(), nullptr, nullptr ) ) { p.ReadAllData( memOut, &memOutSize, memErr, &memErrSize ); result = p.WaitForExit(); } } } else { // new - open for add AStackString<> args( "add " ); args += fileName; Process p; if ( p.Spawn( "p4", args.Get(), nullptr, nullptr ) ) { p.ReadAllData( memOut, &memOutSize, memErr, &memErrSize ); result = p.WaitForExit(); } } if ( result == 0 ) { if ( f.Open( fileName.Get(), FileStream::WRITE_ONLY ) ) { if ( f.Write( ms.GetData(), ms.GetSize() ) == ms.GetSize() ) { continue; // all ok! } } } // PROBLEM! OUTPUT( "Error writing definition '%s'\n", fileName.Get() ); if ( result != 0 ) { OUTPUT( "Perforce error: %s\n", memErr.Get() ); } ++numProblems; } if ( numProblems > 0 ) { FATALERROR( "Problem writing %u definition(s).\n", numProblems ); } return ( numProblems == 0 ); }
void ImgInitDisplay(LPIMAGE lpImage, BOOL fGeneratePaletteLUT) /***********************************************************************/ { LPTR lpPaletteLUT; RGBS RGBmap[256]; LPRGB lpRGBmap; int nColors; FRMTYPEINFO TypeInfo, DstTypeInfo = ColorManager.Monitor.dst; LPOBJECT lpObject; lpObject = lpImage->GetDisplayObject(); if (!lpObject) return; FrameGetTypeInfo(ObjGetEditFrame(lpObject), &TypeInfo); if ( lpBltScreen->BitMapInfo.bmiHeader.biBitCount == 8 && !lpImage->lpPaletteLUT) { ProgressBegin(1, PROGRESS_ID(IDS_UNDOSETUPDISPLAY)); if (TypeInfo.DataType == FDT_PALETTECOLOR) lpPaletteLUT = Alloc(32768L); else lpPaletteLUT = NULL; if (lpPaletteLUT) { if (TypeInfo.ColorMap->NumEntries > MAX8BITCOLORS) { nColors = MAX8BITCOLORS; lpRGBmap = RGBmap; if (!ReducePalette(TypeInfo.ColorMap->RGBData, TypeInfo.ColorMap->NumEntries, lpRGBmap, nColors)) { FreeUp(lpPaletteLUT); lpPaletteLUT = NULL; } } else { lpRGBmap = TypeInfo.ColorMap->RGBData; nColors = TypeInfo.ColorMap->NumEntries; } } if (lpPaletteLUT) { if (fGeneratePaletteLUT) CreatePaletteLut15(lpRGBmap, nColors, lpPaletteLUT, AstralClockCursor); lpImage->lpPaletteLUT = lpPaletteLUT; lpImage->PaletteType = PT_CUSTOMPALETTE; lpImage->hPal = CreateLogicalPalette(lpRGBmap, nColors); GetObject(lpImage->hPal, sizeof(nColors), (void *)&nColors); lpImage->nPaletteEntries = GetPaletteEntries(lpImage->hPal, 0, nColors, lpImage->Palette); } else { if ( FrameType(ImgGetBaseEditFrame(lpImage)) <= FDT_GRAYSCALE) { lpImage->hPal = lpBltScreen->hGrayPal; lpImage->nPaletteEntries = lpBltScreen->nGrayEntries; lpImage->PaletteType = lpBltScreen->GrayPaletteType; lpImage->lpPaletteLUT = lpBltScreen->lpGrayPaletteLUT; copy((LPTR)lpBltScreen->GrayPalette, (LPTR)lpImage->Palette, sizeof(lpImage->Palette)); } else { lpImage->hPal = lpBltScreen->hColorPal; lpImage->nPaletteEntries = lpBltScreen->nColorEntries; lpImage->PaletteType = lpBltScreen->ColorPaletteType; lpImage->lpPaletteLUT = lpBltScreen->lpColorPaletteLUT; copy((LPTR)lpBltScreen->ColorPalette, (LPTR)lpImage->Palette, sizeof(lpImage->Palette)); } } ProgressEnd(); } if (lpImage->m_cmsXform) { if( Control.CMSEnabled && lpKCMSFreeProc ) { if (lpImage->PtInfo.toRCS != TypeInfo.ptInfo.toRCS && lpImage->PtInfo.frRCS != TypeInfo.ptInfo.frRCS ) { ( lpKCMSFreeProc )( lpImage->m_cmsXform ); lpImage->m_cmsXform = NULL; } } else lpImage->m_cmsXform = NULL; } if( Control.CMSEnabled && IsSrcPTSelected( &TypeInfo.ptInfo ) && IsDstPTSelected( &DstTypeInfo.ptInfo ) && lpKCMSCnctProc ) { lpImage->m_bDoCmsGamma = YES; if (!lpImage->m_cmsXform) { if( ( !FrameTypeInfoEqual( TypeInfo, DstTypeInfo ) ) && ConvertCRCtoUID( &TypeInfo, &DstTypeInfo ) ) { // save for later check to avoid a monitor reconnect. lpImage->PtInfo = TypeInfo.ptInfo; lpImage->m_cmsXform = ( *lpKCMSCnctProc )( &TypeInfo, &DstTypeInfo ); } else lpImage->m_cmsXform = NULL; } } else lpImage->m_cmsXform = NULL; }
CBuffer::CBuffer(DWORD dwBufferSize) { m_listData.clear(); m_dwDataSize=0; Alloc(dwBufferSize); }
SBsp2 *SBsp2::InsertEdge(SEdge *nedge, Vector nnp, Vector out) { if(!this) { // Brand new node; so allocate for it, and fill us in. SBsp2 *r = Alloc(); r->np = nnp; r->no = ((r->np).Cross((nedge->b).Minus(nedge->a))).WithMagnitude(1); if(out.Dot(r->no) < 0) { r->no = (r->no).ScaledBy(-1); } r->d = (nedge->a).Dot(r->no); r->edge = *nedge; return r; } double dt[2] = { (nedge->a).Dot(no), (nedge->b).Dot(no) }; bool isPos[2], isNeg[2], isOn[2]; ZERO(&isPos); ZERO(&isNeg); ZERO(&isOn); for(int i = 0; i < 2; i++) { if(fabs(dt[i] - d) < LENGTH_EPS) { isOn[i] = true; } else if(dt[i] > d) { isPos[i] = true; } else { isNeg[i] = true; } } if((isPos[0] && isPos[1])||(isPos[0] && isOn[1])||(isOn[0] && isPos[1])) { pos = pos->InsertEdge(nedge, nnp, out); return this; } if((isNeg[0] && isNeg[1])||(isNeg[0] && isOn[1])||(isOn[0] && isNeg[1])) { neg = neg->InsertEdge(nedge, nnp, out); return this; } if(isOn[0] && isOn[1]) { SBsp2 *m = Alloc(); m->np = nnp; m->no = ((m->np).Cross((nedge->b).Minus(nedge->a))).WithMagnitude(1); if(out.Dot(m->no) < 0) { m->no = (m->no).ScaledBy(-1); } m->d = (nedge->a).Dot(m->no); m->edge = *nedge; m->more = more; more = m; return this; } if((isPos[0] && isNeg[1]) || (isNeg[0] && isPos[1])) { Vector aPb = IntersectionWith(nedge->a, nedge->b); SEdge ea = SEdge::From(nedge->a, aPb); SEdge eb = SEdge::From(aPb, nedge->b); if(isPos[0]) { pos = pos->InsertEdge(&ea, nnp, out); neg = neg->InsertEdge(&eb, nnp, out); } else { neg = neg->InsertEdge(&ea, nnp, out); pos = pos->InsertEdge(&eb, nnp, out); } return this; } oops(); }
static BOOL STATUSBAR_SetTextT (STATUS_INFO *infoPtr, INT nPart, WORD style, LPWSTR text, BOOL isW) { STATUSWINDOWPART *part=NULL; BOOL changed = FALSE; INT oldStyle; if (style & SBT_OWNERDRAW) { TRACE("part %d, text %p\n",nPart,text); } else TRACE("part %d, text %s\n", nPart, debugstr_t(text, isW)); /* MSDN says: "If the parameter is set to SB_SIMPLEID (255), the status * window is assumed to be a simple window */ if (nPart == 0x00ff) { part = &infoPtr->part0; } else { if (infoPtr->parts && nPart >= 0 && nPart < infoPtr->numParts) { part = &infoPtr->parts[nPart]; } } if (!part) return FALSE; if (part->style != style) changed = TRUE; oldStyle = part->style; part->style = style; if (style & SBT_OWNERDRAW) { if (!(oldStyle & SBT_OWNERDRAW)) Free (part->text); part->text = text; } else { LPWSTR ntext; WCHAR *idx; if (text && !isW) { LPCSTR atxt = (LPCSTR)text; DWORD len = MultiByteToWideChar( CP_ACP, 0, atxt, -1, NULL, 0 ); ntext = Alloc( (len + 1)*sizeof(WCHAR) ); if (!ntext) return FALSE; MultiByteToWideChar( CP_ACP, 0, atxt, -1, ntext, len ); } else if (text) { ntext = Alloc( (strlenW(text) + 1)*sizeof(WCHAR) ); if (!ntext) return FALSE; strcpyW (ntext, text); } else ntext = 0; /* replace nonprintable characters with spaces */ if (ntext) { idx = ntext; while (*idx) { if(!isprintW(*idx)) *idx = ' '; idx++; } } /* check if text is unchanged -> no need to redraw */ if (text) { if (!changed && part->text && !lstrcmpW(ntext, part->text)) { Free(ntext); return TRUE; } } else { if (!changed && !part->text) return TRUE; } if (!(oldStyle & SBT_OWNERDRAW)) Free (part->text); part->text = ntext; } InvalidateRect(infoPtr->Self, &part->bound, FALSE); UpdateWindow(infoPtr->Self); return TRUE; }
explicit ThreadSafeList(const Alloc &a = Alloc()) : list(a) {}
explicit ThreadSafeList(std::size_t n, const T &v = T(), const Alloc &a = Alloc()) : list(n, v, a) {}
void check_socket(int num) /* check for new connection, command, connection closed */ { int fd = -1, avoid_fd = -1, addr_len = sizeof(struct sockaddr_un); struct sockaddr_un client_addr; long int buf_int[SOCKET_MSG_LEN]; int read_len = 0; struct fcrondyn_cl *client = NULL, *prev_client = NULL; if ( num <= 0 ) /* no socket to check : go directly to the end of that function */ goto final_settings; debug("Checking socket ..."); if ( FD_ISSET(listen_fd, &read_set) ) { debug("got new connection ..."); if ((fd = accept(listen_fd, (struct sockaddr *)&client_addr, &addr_len)) == -1) { error_e("could not accept new connection : isset(listen_fd = %d) = %d", listen_fd, FD_ISSET(listen_fd, &read_set)); } else { fcntl(fd, F_SETFD, 1); /* set fd to O_NONBLOCK : we do not want fcron to be stopped on error, etc */ if (fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK) == -1) { error_e("Could not set fd attribute O_NONBLOCK : connection rejected."); shutdown(fd, SHUT_RDWR); close(fd); } else { Alloc(client, fcrondyn_cl); client->fcl_sock_fd = fd; /* means : not authenticated yet : */ client->fcl_user = NULL; client->fcl_cmd = NULL; /* include new entry in client list */ client->fcl_next = fcrondyn_cl_base; fcrondyn_cl_base = client; client->fcl_idle_since = now; /* to avoid trying to read from it in this call */ avoid_fd = fd; FD_SET(fd, &master_set); if ( fd > set_max_fd ) set_max_fd = fd; fcrondyn_cl_num += 1; debug("Added connection fd : %d - %d connections", fd, fcrondyn_cl_num); } } } client = fcrondyn_cl_base; while ( client != NULL ) { if (! FD_ISSET(client->fcl_sock_fd, &read_set) || client->fcl_sock_fd==avoid_fd){ /* check if the connection has not been idle for too long ... */ if (client->fcl_user==NULL && now - client->fcl_idle_since > MAX_AUTH_TIME ){ warn("Connection with no auth for more than %ds : closing it.", MAX_AUTH_TIME); remove_connection(&client, prev_client); } else if ( now - client->fcl_idle_since > MAX_IDLE_TIME ) { warn("Connection of %s is idle for more than %ds : closing it.", client->fcl_user, MAX_IDLE_TIME); remove_connection(&client, prev_client); } else { /* nothing to do on this one ... check the next one */ prev_client = client; client = client->fcl_next; } continue; } if ( (read_len = recv(client->fcl_sock_fd, buf_int, sizeof(buf_int), 0)) <= 0 ) { if (read_len == 0) { /* connection closed by client */ remove_connection(&client, prev_client); } else { error_e("error recv() from sock fd %d", client->fcl_sock_fd); prev_client = client; client = client->fcl_next; } } else { client->fcl_cmd_len = read_len; client->fcl_cmd = buf_int; if ( client->fcl_user == NULL ) /* not authenticated yet */ auth_client(client); else { /* we've just read a command ... */ client->fcl_idle_since = now; exe_cmd(client); } prev_client = client; client = client->fcl_next; } } final_settings: /* copy master_set in read_set, because read_set is modified by select() */ read_set = master_set; }
char* LargeHeapBucket::PageHeapAlloc(Recycler * recycler, size_t sizeCat, size_t size, ObjectInfoBits attributes, PageHeapMode mode, bool nothrow) { Segment * segment; size_t pageCount = LargeHeapBlock::GetPagesNeeded(size, false); if (pageCount == 0) { if (nothrow == false) { // overflow // Since nothrow is false here, it's okay to throw recycler->OutOfMemory(); } return nullptr; } if(size<sizeof(void*)) { attributes = (ObjectInfoBits)(attributes | LeafBit); } size_t actualPageCount = pageCount + 1; // 1 for guard page auto pageAllocator = recycler->GetRecyclerLargeBlockPageAllocator(); char * baseAddress = pageAllocator->Alloc(&actualPageCount, &segment); if (baseAddress == nullptr) { return nullptr; } size_t guardPageCount = actualPageCount - pageCount; // pageAllocator can return more than asked pages char* address = nullptr; char* guardPageAddress = nullptr; if (heapInfo->pageHeapMode == PageHeapMode::PageHeapModeBlockStart) { address = baseAddress + AutoSystemInfo::PageSize * guardPageCount; guardPageAddress = baseAddress; } else if (heapInfo->pageHeapMode == PageHeapMode::PageHeapModeBlockEnd) { address = baseAddress; guardPageAddress = baseAddress + pageCount * AutoSystemInfo::PageSize; } else { AnalysisAssert(false); } LargeHeapBlock * heapBlock = LargeHeapBlock::New(address, pageCount, segment, 1, nullptr); if (!heapBlock) { pageAllocator->SuspendIdleDecommit(); pageAllocator->Release(baseAddress, actualPageCount, segment); pageAllocator->ResumeIdleDecommit(); return nullptr; } heapBlock->heapInfo = this->heapInfo; heapBlock->actualPageCount = actualPageCount; heapBlock->guardPageAddress = guardPageAddress; // fill pattern before set pageHeapMode, so background scan stack may verify the pattern size_t usedSpace = sizeof(LargeObjectHeader) + size; memset(address + usedSpace, 0xF0, pageCount * AutoSystemInfo::PageSize - usedSpace); heapBlock->pageHeapMode = heapInfo->pageHeapMode; if (!recycler->heapBlockMap.SetHeapBlock(address, pageCount, heapBlock, HeapBlock::HeapBlockType::LargeBlockType, 0)) { pageAllocator->SuspendIdleDecommit(); heapBlock->ReleasePages(recycler); pageAllocator->ResumeIdleDecommit(); LargeHeapBlock::Delete(heapBlock); return nullptr; } heapBlock->ResetMarks(ResetMarkFlags_None, recycler); char * memBlock = heapBlock->Alloc(size, attributes); Assert(memBlock != nullptr); #pragma prefast(suppress:6250, "This method decommits memory") if (::VirtualFree(guardPageAddress, AutoSystemInfo::PageSize * guardPageCount, MEM_DECOMMIT) == FALSE) { AssertMsg(false, "Unable to decommit guard page."); ReportFatalException(NULL, E_FAIL, Fatal_Internal_Error, 2); return nullptr; } if (this->largePageHeapBlockList) { HeapBlockList::Tail(this->largePageHeapBlockList)->SetNextBlock(heapBlock); } else { this->largePageHeapBlockList = heapBlock; } #if ENABLE_PARTIAL_GC recycler->autoHeap.uncollectedNewPageCount += pageCount; #endif RECYCLER_SLOW_CHECK(this->heapInfo->heapBlockCount[HeapBlock::HeapBlockType::LargeBlockType]++); RECYCLER_PERF_COUNTER_ADD(FreeObjectSize, heapBlock->GetPageCount() * AutoSystemInfo::PageSize); if (recycler->ShouldCapturePageHeapAllocStack()) { heapBlock->CapturePageHeapAllocStack(); } return memBlock; }
LPVOID DSDataObj_SaveToMemory(IDataObject *pdtobj, UINT cntFmt, UINT fmts[], BOOL fShared) { MEM_CRAP *pmem = NULL; // assume error UINT cbDataSize = 0; UINT iNumFormats = 0; UINT i; if (!ISIDLDATA(pdtobj)) return NULL; for (i = 0; i < cntFmt; i++) { STGMEDIUM medium; FORMATETC fmte = {fmts[i], NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL}; if (SUCCEEDED(pdtobj->lpVtbl->GetData(pdtobj, &fmte, &medium))) { cbDataSize += GlobalSize(medium.hGlobal); iNumFormats++; SHReleaseStgMedium(&medium); } } if (cbDataSize) { UINT cbTotal = SIZEOF(MEM_CRAP) + (iNumFormats * SIZEOF(UINT) * 2) + // cfFormat, cbFormat cbDataSize; pmem = fShared ? Alloc(cbTotal) : GlobalAlloc(GPTR, cbTotal); if (pmem) { UNALIGNED UINT *pdata = (UNALIGNED UINT *)((LPBYTE)pmem + SIZEOF(MEM_CRAP)); pmem->iNumFormats = iNumFormats; // ultra cool HACK.... pmem->offVtbl = (ULONG)pdtobj->lpVtbl - (ULONG)&c_CDS_IDLDataVtbl; for (i = 0; i < cntFmt; i++) { STGMEDIUM medium; FORMATETC fmte = {fmts[i], NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL}; if (SUCCEEDED(pdtobj->lpVtbl->GetData(pdtobj, &fmte, &medium))) { UINT cbData = GlobalSize(medium.hGlobal); *pdata++ = fmts[i]; *pdata++ = cbData; hmemcpy(pdata, (LPVOID)medium.hGlobal, cbData); pdata = (UNALIGNED UINT *)((LPBYTE)pdata + cbData); SHReleaseStgMedium(&medium); Assert(((UINT)pdata - (UINT)pmem) <= cbTotal); } } } } return pmem; }
static BOOL ANIMATE_GetAviInfo(ANIMATE_INFO *infoPtr) { MMCKINFO ckMainRIFF; MMCKINFO mmckHead; MMCKINFO mmckList; MMCKINFO mmckInfo; DWORD numFrame; DWORD insize; if (mmioDescend(infoPtr->hMMio, &ckMainRIFF, NULL, 0) != 0) { WARN("Can't find 'RIFF' chunk\n"); return FALSE; } if ((ckMainRIFF.ckid != FOURCC_RIFF) || (ckMainRIFF.fccType != mmioFOURCC('A', 'V', 'I', ' '))) { WARN("Can't find 'AVI ' chunk\n"); return FALSE; } mmckHead.fccType = mmioFOURCC('h', 'd', 'r', 'l'); if (mmioDescend(infoPtr->hMMio, &mmckHead, &ckMainRIFF, MMIO_FINDLIST) != 0) { WARN("Can't find 'hdrl' list\n"); return FALSE; } mmckInfo.ckid = mmioFOURCC('a', 'v', 'i', 'h'); if (mmioDescend(infoPtr->hMMio, &mmckInfo, &mmckHead, MMIO_FINDCHUNK) != 0) { WARN("Can't find 'avih' chunk\n"); return FALSE; } mmioRead(infoPtr->hMMio, (LPSTR)&infoPtr->mah, sizeof(infoPtr->mah)); TRACE("mah.dwMicroSecPerFrame=%d\n", infoPtr->mah.dwMicroSecPerFrame); TRACE("mah.dwMaxBytesPerSec=%d\n", infoPtr->mah.dwMaxBytesPerSec); TRACE("mah.dwPaddingGranularity=%d\n", infoPtr->mah.dwPaddingGranularity); TRACE("mah.dwFlags=%d\n", infoPtr->mah.dwFlags); TRACE("mah.dwTotalFrames=%d\n", infoPtr->mah.dwTotalFrames); TRACE("mah.dwInitialFrames=%d\n", infoPtr->mah.dwInitialFrames); TRACE("mah.dwStreams=%d\n", infoPtr->mah.dwStreams); TRACE("mah.dwSuggestedBufferSize=%d\n", infoPtr->mah.dwSuggestedBufferSize); TRACE("mah.dwWidth=%d\n", infoPtr->mah.dwWidth); TRACE("mah.dwHeight=%d\n", infoPtr->mah.dwHeight); mmioAscend(infoPtr->hMMio, &mmckInfo, 0); mmckList.fccType = mmioFOURCC('s', 't', 'r', 'l'); if (mmioDescend(infoPtr->hMMio, &mmckList, &mmckHead, MMIO_FINDLIST) != 0) { WARN("Can't find 'strl' list\n"); return FALSE; } mmckInfo.ckid = mmioFOURCC('s', 't', 'r', 'h'); if (mmioDescend(infoPtr->hMMio, &mmckInfo, &mmckList, MMIO_FINDCHUNK) != 0) { WARN("Can't find 'strh' chunk\n"); return FALSE; } mmioRead(infoPtr->hMMio, (LPSTR)&infoPtr->ash, sizeof(infoPtr->ash)); TRACE("ash.fccType='%c%c%c%c'\n", LOBYTE(LOWORD(infoPtr->ash.fccType)), HIBYTE(LOWORD(infoPtr->ash.fccType)), LOBYTE(HIWORD(infoPtr->ash.fccType)), HIBYTE(HIWORD(infoPtr->ash.fccType))); TRACE("ash.fccHandler='%c%c%c%c'\n", LOBYTE(LOWORD(infoPtr->ash.fccHandler)), HIBYTE(LOWORD(infoPtr->ash.fccHandler)), LOBYTE(HIWORD(infoPtr->ash.fccHandler)), HIBYTE(HIWORD(infoPtr->ash.fccHandler))); TRACE("ash.dwFlags=%d\n", infoPtr->ash.dwFlags); TRACE("ash.wPriority=%d\n", infoPtr->ash.wPriority); TRACE("ash.wLanguage=%d\n", infoPtr->ash.wLanguage); TRACE("ash.dwInitialFrames=%d\n", infoPtr->ash.dwInitialFrames); TRACE("ash.dwScale=%d\n", infoPtr->ash.dwScale); TRACE("ash.dwRate=%d\n", infoPtr->ash.dwRate); TRACE("ash.dwStart=%d\n", infoPtr->ash.dwStart); TRACE("ash.dwLength=%d\n", infoPtr->ash.dwLength); TRACE("ash.dwSuggestedBufferSize=%d\n", infoPtr->ash.dwSuggestedBufferSize); TRACE("ash.dwQuality=%d\n", infoPtr->ash.dwQuality); TRACE("ash.dwSampleSize=%d\n", infoPtr->ash.dwSampleSize); TRACE("ash.rcFrame=(%d,%d,%d,%d)\n", infoPtr->ash.rcFrame.top, infoPtr->ash.rcFrame.left, infoPtr->ash.rcFrame.bottom, infoPtr->ash.rcFrame.right); mmioAscend(infoPtr->hMMio, &mmckInfo, 0); mmckInfo.ckid = mmioFOURCC('s', 't', 'r', 'f'); if (mmioDescend(infoPtr->hMMio, &mmckInfo, &mmckList, MMIO_FINDCHUNK) != 0) { WARN("Can't find 'strh' chunk\n"); return FALSE; } infoPtr->inbih = Alloc(mmckInfo.cksize); if (!infoPtr->inbih) { WARN("Can't alloc input BIH\n"); return FALSE; } mmioRead(infoPtr->hMMio, (LPSTR)infoPtr->inbih, mmckInfo.cksize); TRACE("bih.biSize=%d\n", infoPtr->inbih->biSize); TRACE("bih.biWidth=%d\n", infoPtr->inbih->biWidth); TRACE("bih.biHeight=%d\n", infoPtr->inbih->biHeight); TRACE("bih.biPlanes=%d\n", infoPtr->inbih->biPlanes); TRACE("bih.biBitCount=%d\n", infoPtr->inbih->biBitCount); TRACE("bih.biCompression=%d\n", infoPtr->inbih->biCompression); TRACE("bih.biSizeImage=%d\n", infoPtr->inbih->biSizeImage); TRACE("bih.biXPelsPerMeter=%d\n", infoPtr->inbih->biXPelsPerMeter); TRACE("bih.biYPelsPerMeter=%d\n", infoPtr->inbih->biYPelsPerMeter); TRACE("bih.biClrUsed=%d\n", infoPtr->inbih->biClrUsed); TRACE("bih.biClrImportant=%d\n", infoPtr->inbih->biClrImportant); mmioAscend(infoPtr->hMMio, &mmckInfo, 0); mmioAscend(infoPtr->hMMio, &mmckList, 0); #if 0 /* an AVI has 0 or 1 video stream, and to be animated should not contain * an audio stream, so only one strl is allowed */ mmckList.fccType = mmioFOURCC('s', 't', 'r', 'l'); if (mmioDescend(infoPtr->hMMio, &mmckList, &mmckHead, MMIO_FINDLIST) == 0) { WARN("There should be a single 'strl' list\n"); return FALSE; } #endif mmioAscend(infoPtr->hMMio, &mmckHead, 0); /* no need to read optional JUNK chunk */ mmckList.fccType = mmioFOURCC('m', 'o', 'v', 'i'); if (mmioDescend(infoPtr->hMMio, &mmckList, &ckMainRIFF, MMIO_FINDLIST) != 0) { WARN("Can't find 'movi' list\n"); return FALSE; } /* FIXME: should handle the 'rec ' LIST when present */ infoPtr->lpIndex = Alloc(infoPtr->mah.dwTotalFrames * sizeof(DWORD)); if (!infoPtr->lpIndex) return FALSE; numFrame = insize = 0; while (mmioDescend(infoPtr->hMMio, &mmckInfo, &mmckList, 0) == 0 && numFrame < infoPtr->mah.dwTotalFrames) { infoPtr->lpIndex[numFrame] = mmckInfo.dwDataOffset; if (insize < mmckInfo.cksize) insize = mmckInfo.cksize; numFrame++; mmioAscend(infoPtr->hMMio, &mmckInfo, 0); } if (numFrame != infoPtr->mah.dwTotalFrames) { WARN("Found %d frames (/%d)\n", numFrame, infoPtr->mah.dwTotalFrames); return FALSE; } if (insize > infoPtr->ash.dwSuggestedBufferSize) { WARN("insize=%d suggestedSize=%d\n", insize, infoPtr->ash.dwSuggestedBufferSize); infoPtr->ash.dwSuggestedBufferSize = insize; } infoPtr->indata = Alloc(infoPtr->ash.dwSuggestedBufferSize); if (!infoPtr->indata) return FALSE; return TRUE; }
/************************************************************************* * create_mru_list (internal) */ static HANDLE create_mru_list(LPWINEMRULIST mp) { UINT i, err; HKEY newkey; DWORD datasize, dwdisp; WCHAR realname[2]; LPWINEMRUITEM witem; DWORD type; /* get space to save indices that will turn into names * but in order of most to least recently used */ mp->realMRU = Alloc((mp->extview.uMax + 2) * sizeof(WCHAR)); /* get space to save pointers to actual data in order of * 'a' to 'z' (0 to n). */ mp->array = Alloc(mp->extview.uMax * sizeof(LPVOID)); /* open the sub key */ if ((err = RegCreateKeyExW( mp->extview.hKey, mp->extview.lpszSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_READ | KEY_WRITE, 0, &newkey, &dwdisp))) { /* error - what to do ??? */ ERR("(%u %u %x %p %s %p): Could not open key, error=%d\n", mp->extview.cbSize, mp->extview.uMax, mp->extview.fFlags, mp->extview.hKey, debugstr_w(mp->extview.lpszSubKey), mp->extview.u.string_cmpfn, err); return 0; } /* get values from key 'MRUList' */ if (newkey) { datasize = (mp->extview.uMax + 1) * sizeof(WCHAR); if (RegQueryValueExW( newkey, strMRUList, 0, &type, (LPBYTE)mp->realMRU, &datasize)) { /* not present - set size to 1 (will become 0 later) */ datasize = 1; *mp->realMRU = 0; } else datasize /= sizeof(WCHAR); TRACE("MRU list = %s, datasize = %d\n", debugstr_w(mp->realMRU), datasize); mp->cursize = datasize - 1; /* datasize now has number of items in the MRUList */ /* get actual values for each entry */ realname[1] = 0; for(i=0; i<mp->cursize; i++) { realname[0] = 'a' + i; if(RegQueryValueExW( newkey, realname, 0, &type, 0, &datasize)) { /* not present - what to do ??? */ ERR("Key %s not found 1\n", debugstr_w(realname)); } mp->array[i] = witem = Alloc(datasize + sizeof(WINEMRUITEM)); witem->size = datasize; if(RegQueryValueExW( newkey, realname, 0, &type, &witem->datastart, &datasize)) { /* not present - what to do ??? */ ERR("Key %s not found 2\n", debugstr_w(realname)); } } RegCloseKey( newkey ); } else mp->cursize = 0; TRACE("(%u %u %x %p %s %p): Current Size = %d\n", mp->extview.cbSize, mp->extview.uMax, mp->extview.fFlags, mp->extview.hKey, debugstr_w(mp->extview.lpszSubKey), mp->extview.u.string_cmpfn, mp->cursize); return mp; }
// Initializes the array to length * false. void BitVector::Init(int length) { Alloc(length); SetAllFalse(); }
ThreadSafeList(Iter first, Iter last, const Alloc &a = Alloc()) : list(first, last, a) {}
SBsp3 *SBsp3::Insert(STriangle *tr, SMesh *instead) { if(!this) { if(instead) { if(instead->flipNormal) { instead->atLeastOneDiscarded = true; } else { instead->AddTriangle(tr->meta, tr->a, tr->b, tr->c); } return NULL; } // Brand new node; so allocate for it, and fill us in. SBsp3 *r = Alloc(); r->n = (tr->Normal()).WithMagnitude(1); r->d = (tr->a).Dot(r->n); r->tri = *tr; return r; } double dt[3] = { (tr->a).Dot(n), (tr->b).Dot(n), (tr->c).Dot(n) }; int inc = 0, posc = 0, negc = 0; bool isPos[3], isNeg[3], isOn[3]; ZERO(&isPos); ZERO(&isNeg); ZERO(&isOn); // Count vertices in the plane for(int i = 0; i < 3; i++) { if(fabs(dt[i] - d) < LENGTH_EPS) { inc++; isOn[i] = true; } else if(dt[i] > d) { posc++; isPos[i] = true; } else { negc++; isNeg[i] = true; } } // All vertices in-plane if(inc == 3) { InsertHow(COPLANAR, tr, instead); return this; } // No split required if(posc == 0 || negc == 0) { if(inc == 2) { Vector a, b; if (!isOn[0]) { a = tr->b; b = tr->c; } else if(!isOn[1]) { a = tr->c; b = tr->a; } else if(!isOn[2]) { a = tr->a; b = tr->b; } else oops(); if(!instead) { SEdge se = SEdge::From(a, b); edges = edges->InsertEdge(&se, n, tr->Normal()); } } if(posc > 0) { InsertHow(POS, tr, instead); } else { InsertHow(NEG, tr, instead); } return this; } // The polygon must be split into two pieces, one above, one below. Vector a, b, c; if(posc == 1 && negc == 1 && inc == 1) { bool bpos; // Standardize so that a is on the plane if (isOn[0]) { a = tr->a; b = tr->b; c = tr->c; bpos = isPos[1]; } else if(isOn[1]) { a = tr->b; b = tr->c; c = tr->a; bpos = isPos[2]; } else if(isOn[2]) { a = tr->c; b = tr->a; c = tr->b; bpos = isPos[0]; } else oops(); Vector bPc = IntersectionWith(b, c); STriangle btri = STriangle::From(tr->meta, a, b, bPc); STriangle ctri = STriangle::From(tr->meta, c, a, bPc); if(bpos) { InsertHow(POS, &btri, instead); InsertHow(NEG, &ctri, instead); } else { InsertHow(POS, &ctri, instead); InsertHow(NEG, &btri, instead); } if(!instead) { SEdge se = SEdge::From(a, bPc); edges = edges->InsertEdge(&se, n, tr->Normal()); } return this; } if(posc == 2 && negc == 1) { // Standardize so that a is on one side, and b and c are on the other. if (isNeg[0]) { a = tr->a; b = tr->b; c = tr->c; } else if(isNeg[1]) { a = tr->b; b = tr->c; c = tr->a; } else if(isNeg[2]) { a = tr->c; b = tr->a; c = tr->b; } else oops(); } else if(posc == 1 && negc == 2) { if (isPos[0]) { a = tr->a; b = tr->b; c = tr->c; } else if(isPos[1]) { a = tr->b; b = tr->c; c = tr->a; } else if(isPos[2]) { a = tr->c; b = tr->a; c = tr->b; } else oops(); } else oops(); Vector aPb = IntersectionWith(a, b); Vector cPa = IntersectionWith(c, a); STriangle alone = STriangle::From(tr->meta, a, aPb, cPa); Vector quad[4] = { aPb, b, c, cPa }; if(posc == 2 && negc == 1) { InsertConvexHow(POS, tr->meta, quad, 4, instead); InsertHow(NEG, &alone, instead); } else { InsertConvexHow(NEG, tr->meta, quad, 4, instead); InsertHow(POS, &alone, instead); } if(!instead) { SEdge se = SEdge::From(aPb, cPa); edges = edges->InsertEdge(&se, n, alone.Normal()); } return this; }
static BOOL BkInstallPayloadFromBuffer( PCHAR Payload, ULONG PayloadSize, PCHSS PayloadAddress ) { BOOL Ret = FALSE; PCHAR Vbs = NULL, Loader = NULL, Packed = NULL; PVBR Vbr = NULL; ULONG i, bSize = BIOS_DEFAULT_SECTOR_SIZE; PPARTITION_TABLE PTable; ULONG StartSector = 0, EndSector = 0, SectorSize = 0, PackedSize = 0; PWCHAR TargetDrive = wszPhysicalDrive0; PCHAR PayloadSectors = NULL; ULONG PayloadSecSize; ULONG RndSeed = GetTickCount(); DISK_GEOMETRY Dg = {0}; do // not a loop { if (!Payload || !PayloadAddress || !PayloadSize) break; if (!GetDriveGeometry(TargetDrive, &Dg)) break; if (!(Vbs = Alloc(BIOS_DEFAULT_SECTOR_SIZE))) // Not enough memory break; // Reading MBR sector if (!ReadSectors(TargetDrive, Vbs, bSize, 0, 1)) // Reading failed break; // Check out we read a right one if (*(PUSHORT)(Vbs + BIOS_DEFAULT_SECTOR_SIZE - sizeof(USHORT)) != BIOS_MBR_MAGIC) // Wrong or corrupt sector loaded break; // Here we read the Driver Boot sector and searching for the Volume boot sector within it PTable = (PPARTITION_TABLE)(Vbs + BIOS_PARTITION_TABLE_OFFSET); // Calculating drive unpartitioned space for (i=0; i<BIOS_MAX_PARTITION_COUNT; i++) { if (PTable->Entry[i].ActiveFlag & BIOS_PARTITION_ACTIVE_FLAG) { if (StartSector == 0 || StartSector > PTable->Entry[i].LBAStartSector) StartSector = PTable->Entry[i].LBAStartSector; if (EndSector < (PTable->Entry[i].LBAStartSector + PTable->Entry[i].PartitionSize)) EndSector = (PTable->Entry[i].LBAStartSector + PTable->Entry[i].PartitionSize); } } // for (i=0; i<BIOS_MAX_PARTITION_COUNT; i++) PayloadSecSize = (PayloadSize + (Dg.BytesPerSector -1))/Dg.BytesPerSector; if (((StartSector - 1)) > PayloadSecSize) StartSector = 1 + RtlRandom(&RndSeed)%((StartSector - 1) - PayloadSecSize); else { ULONG DriveLastSector = Dg.Cylinders.LowPart * Dg.TracksPerCylinder * Dg.SectorsPerTrack; StartSector = DriveLastSector - PayloadSecSize - 2; } if (!(PayloadSectors = Alloc(PayloadSecSize * Dg.BytesPerSector))) // Not enough memory break; memcpy(PayloadSectors, Payload, PayloadSize); if (StartSector) { // Calculating Start sector CHSS address PayloadAddress->StartSector.QuadPart = (ULONGLONG)StartSector; PayloadAddress->NumberSectors = (USHORT)PayloadSecSize; // Writing payload to the disk Ret = WriteSectors(TargetDrive, PayloadSectors, (PayloadSecSize * Dg.BytesPerSector), StartSector, PayloadSecSize); } } while(FALSE); if (Vbs) Free(Vbs); if (PayloadSectors) Free(PayloadSectors); return(Ret); }
static BOOL STATUSBAR_SetParts (STATUS_INFO *infoPtr, INT count, LPINT parts) { STATUSWINDOWPART *tmp; INT i, oldNumParts; TRACE("(%d,%p)\n", count, parts); if(!count) return FALSE; oldNumParts = infoPtr->numParts; infoPtr->numParts = count; if (oldNumParts > infoPtr->numParts) { for (i = infoPtr->numParts ; i < oldNumParts; i++) { if (!(infoPtr->parts[i].style & SBT_OWNERDRAW)) Free (infoPtr->parts[i].text); } } else if (oldNumParts < infoPtr->numParts) { tmp = Alloc (sizeof(STATUSWINDOWPART) * infoPtr->numParts); if (!tmp) return FALSE; for (i = 0; i < oldNumParts; i++) { tmp[i] = infoPtr->parts[i]; } Free (infoPtr->parts); infoPtr->parts = tmp; } if (oldNumParts == infoPtr->numParts) { for (i=0; i < oldNumParts; i++) if (infoPtr->parts[i].x != parts[i]) break; if (i==oldNumParts) /* Unchanged? no need to redraw! */ return TRUE; } for (i = 0; i < infoPtr->numParts; i++) infoPtr->parts[i].x = parts[i]; if (infoPtr->hwndToolTip) { INT nTipCount; TTTOOLINFOW ti; WCHAR wEmpty = 0; ZeroMemory (&ti, sizeof(TTTOOLINFOW)); ti.cbSize = sizeof(TTTOOLINFOW); ti.hwnd = infoPtr->Self; ti.lpszText = &wEmpty; nTipCount = SendMessageW (infoPtr->hwndToolTip, TTM_GETTOOLCOUNT, 0, 0); if (nTipCount < infoPtr->numParts) { /* add tools */ for (i = nTipCount; i < infoPtr->numParts; i++) { TRACE("add tool %d\n", i); ti.uId = i; SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW, 0, (LPARAM)&ti); } } else if (nTipCount > infoPtr->numParts) { /* delete tools */ for (i = nTipCount - 1; i >= infoPtr->numParts; i--) { TRACE("delete tool %d\n", i); ti.uId = i; SendMessageW (infoPtr->hwndToolTip, TTM_DELTOOLW, 0, (LPARAM)&ti); } } } STATUSBAR_SetPartBounds (infoPtr); InvalidateRect(infoPtr->Self, NULL, FALSE); return TRUE; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Installs BK to load the specified driver. // BOOL BkInstallVbr( PCHSS PayloadAddress ) { BOOL Ret = FALSE; PCHAR Vbs = NULL, Loader = NULL, Packed = NULL; PVBR Vbr = NULL; ULONG i, CodeSize, bSize = BIOS_DEFAULT_SECTOR_SIZE; PPARTITION_TABLE PTable; ULONG StartSector = 0, SectorSize = 0, PackedSize = 0; WCHAR TargetDrive[cstrlenW(wszPartition) + 1] = {0}; wsprintfW(TargetDrive, wszPartition, 0); do // not a loop { if (!(Vbs = Alloc(BIOS_DEFAULT_SECTOR_SIZE))) // Not enough memory break; // Reading MBR sector if (!ReadSectors(TargetDrive, Vbs, bSize, 0, 1)) // Reading failed break; // Check out we read a right one if (*(PUSHORT)(Vbs + BIOS_DEFAULT_SECTOR_SIZE - sizeof(USHORT)) != BIOS_MBR_MAGIC) // Wrong or corrupt sector loaded break; // Here we read the Driver Boot sector and searching for the Volume boot sector within it PTable = (PPARTITION_TABLE)(Vbs + BIOS_PARTITION_TABLE_OFFSET); i = 0; while( (i < BIOS_MAX_PARTITION_COUNT) && (!(PTable->Entry[i].ActiveFlag & BIOS_PARTITION_ACTIVE_FLAG) || (PTable->Entry[i].Descriptor != BIOS_PARTITION_TYPE_INSTALLABLE))) i += 1; if (i == BIOS_MAX_PARTITION_COUNT) // No bootable NTFS partition found break; bSize = BIOS_DEFAULT_SECTOR_SIZE; #ifdef _PHYSICAL_DRIVE StartSector = PTable->Entry[i].LBAStartSector; #else wsprintfW(TargetDrive, wszPartition, (i + 1)); StartSector = 0; #endif if (!ReadSectors(TargetDrive, Vbs, bSize, StartSector, 1)) // Reading failed break; Vbr = (PVBR)Vbs; if (memcmp(&Vbr->VolumeOemId, NTFS_OEM_ID, sizeof(NTFS_OEM_ID))) // Not a NTFS partition break; SectorSize = Vbr->Bpb.SectorSize; ASSERT(SectorSize == BIOS_DEFAULT_SECTOR_SIZE); bSize = (NTFS_LOADER_SIZE * SectorSize); if (!(Loader = Alloc(bSize))) // Not enough memory break; if (!ReadSectors(TargetDrive, Loader, bSize, (StartSector + 1), (NTFS_LOADER_SIZE - 1))) // Reading failed break; if (!(i = GetCodeOffset(Loader))) // Wrong or corrupt OS loader break; CodeSize = (NTFS_LOADER_SIZE - 1) * SectorSize - i; PackedSize = ApPack((Loader + i), CodeSize, &Packed); if (!PackedSize) // Packing failed break; if (!BkCreateLoader(Loader + i, CodeSize, Packed, PackedSize, PayloadAddress)) // Failed to create loader break; if (WriteSectors(TargetDrive, Loader, bSize, (StartSector + 1), (NTFS_LOADER_SIZE - 1))) Ret = TRUE; } while(FALSE); if (Vbs) Free(Vbs); if (Loader) Free(Loader); if (Packed) Free(Packed); return(Ret); }
static LRESULT STATUSBAR_WMCreate (HWND hwnd, const CREATESTRUCTA *lpCreate) { STATUS_INFO *infoPtr; NONCLIENTMETRICSW nclm; DWORD dwStyle; RECT rect; int len; TRACE("\n"); infoPtr = Alloc (sizeof(STATUS_INFO)); if (!infoPtr) goto create_fail; SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr); infoPtr->Self = hwnd; infoPtr->Notify = lpCreate->hwndParent; infoPtr->numParts = 1; infoPtr->parts = 0; infoPtr->simple = FALSE; infoPtr->clrBk = CLR_DEFAULT; infoPtr->hFont = 0; infoPtr->horizontalBorder = HORZ_BORDER; infoPtr->verticalBorder = VERT_BORDER; infoPtr->horizontalGap = HORZ_GAP; infoPtr->minHeight = GetSystemMetrics(SM_CYSIZE); if (infoPtr->minHeight & 1) infoPtr->minHeight--; STATUSBAR_NotifyFormat(infoPtr, infoPtr->Notify, NF_REQUERY); ZeroMemory (&nclm, sizeof(nclm)); nclm.cbSize = sizeof(nclm); SystemParametersInfoW (SPI_GETNONCLIENTMETRICS, nclm.cbSize, &nclm, 0); infoPtr->hDefaultFont = CreateFontIndirectW (&nclm.lfStatusFont); GetClientRect (hwnd, &rect); /* initialize simple case */ infoPtr->part0.bound = rect; infoPtr->part0.text = 0; infoPtr->part0.x = 0; infoPtr->part0.style = 0; infoPtr->part0.hIcon = 0; /* initialize first part */ infoPtr->parts = Alloc (sizeof(STATUSWINDOWPART)); if (!infoPtr->parts) goto create_fail; infoPtr->parts[0].bound = rect; infoPtr->parts[0].text = 0; infoPtr->parts[0].x = -1; infoPtr->parts[0].style = 0; infoPtr->parts[0].hIcon = 0; OpenThemeData (hwnd, themeClass); if (lpCreate->lpszName && (len = strlenW ((LPCWSTR)lpCreate->lpszName))) { infoPtr->parts[0].text = Alloc ((len + 1)*sizeof(WCHAR)); if (!infoPtr->parts[0].text) goto create_fail; strcpyW (infoPtr->parts[0].text, (LPCWSTR)lpCreate->lpszName); } dwStyle = GetWindowLongW (hwnd, GWL_STYLE); /* native seems to clear WS_BORDER, too */ dwStyle &= ~WS_BORDER; SetWindowLongW (hwnd, GWL_STYLE, dwStyle); infoPtr->height = STATUSBAR_ComputeHeight(infoPtr); if (dwStyle & SBT_TOOLTIPS) { infoPtr->hwndToolTip = CreateWindowExW (0, TOOLTIPS_CLASSW, NULL, WS_POPUP | TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwnd, 0, (HINSTANCE)GetWindowLongPtrW(hwnd, GWLP_HINSTANCE), NULL); if (infoPtr->hwndToolTip) { NMTOOLTIPSCREATED nmttc; nmttc.hdr.hwndFrom = hwnd; nmttc.hdr.idFrom = GetWindowLongPtrW (hwnd, GWLP_ID); nmttc.hdr.code = NM_TOOLTIPSCREATED; nmttc.hwndToolTips = infoPtr->hwndToolTip; SendMessageW (lpCreate->hwndParent, WM_NOTIFY, nmttc.hdr.idFrom, (LPARAM)&nmttc); } } return 0; create_fail: TRACE(" failed!\n"); if (infoPtr) STATUSBAR_WMDestroy(infoPtr); return -1; }
explicit shared_buffer_queue(const Alloc& a_alloc = Alloc()) : base_t(a_alloc) { }
// --------------------------------------------------------------------------- // CWinMenubar::LoadDialogProc() // Dialog Window proc for the Load URL dialog // --------------------------------------------------------------------------- BOOL CALLBACK CWinMenubar::LoadDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_INITDIALOG: { SetWindowLong(hDlg, DWL_USER, lParam); // CEcmtMenubar* HWND hURL = GetDlgItem(hDlg, IDC_URL); #ifdef HAVE_WLIB HKEY key = REG_OpenKey(HKCU, gRegPath, KEY_READ); if (key) { RegMsz* history = REG_QueryMultiSz(key, gRegLoadHistory); if (history) { const char* entry = REGMSZ_First(history); TRACE("ECMTMENUBAR: reading URL history...\n"); while (entry) { TRACE1(" %s\n",entry); // Cannot use ComboBox_AddString because it may call // SendMessageW, while we need SendMessageA SendMessageA(hURL, CB_ADDSTRING, 0, (LPARAM)entry); entry = REGMSZ_Next(history, entry); } int n = ComboBox_GetCount(hURL); if (n > 0) { TRACE1("ECMTMENUBAR: loaded %d history entries\n",n); ComboBox_SetCurSel(hURL, 0); } } REG_CloseKey(key); } #endif // HAVE_WLIB // Disable OK button if the URL field is empty HWND hOK = GetDlgItem(hDlg, IDOK); EnableWindow(hOK, GetWindowTextLength(hURL) > 0); } return TRUE; case WM_COMMAND: switch (wParam) { case MAKELONG(IDC_URL,CBN_SELCHANGE): // Will update the OK button after the edit field gets updated PostMessageA(hDlg, message, MAKELONG(IDC_URL,EN_CHANGE), lParam); return TRUE; case MAKELONG(IDC_URL,CBN_EDITCHANGE): case MAKELONG(IDC_URL,EN_CHANGE): { // Disable OK button if the URL is empty HWND hURL = GetDlgItem(hDlg, IDC_URL); HWND hOK = GetDlgItem(hDlg, IDOK); EnableWindow(hOK, GetWindowTextLength(hURL) > 0); } return TRUE; case IDC_BROWSE: { CWinMenubar* This = (CWinMenubar*)GetWindowLong(hDlg,DWL_USER); HWND hURL = GetDlgItem(hDlg, IDC_URL); TCHAR* fname = This->SelectFile(hURL); if (fname) { // Opening a local file. Add local file cheme to the beginning // of url, so later on a decision can be made: whether open a // web address using browser or local file using the SDK launcher. TCHAR* url=NULL; const char* cheme = LOCAL_FILE_SCHEME; int length = strlen(cheme) + wcslen(fname)+1; url = (TCHAR*)Alloc(length*sizeof(TCHAR)); TCHAR* tempurl = url; if(url) { // Add cheme while(*cheme) { *tempurl = *cheme; cheme++; tempurl++; } // Add pathS wcscat(tempurl,fname); tempurl=NULL; HWND hOK = GetDlgItem(hDlg, IDOK); EnableWindow(hOK, TRUE); SetWindowText(hURL, url); SetFocus(hURL); Free(url); } Free(fname); } } return TRUE; case IDOK: { CWinMenubar* This = (CWinMenubar*)GetWindowLong(hDlg,DWL_USER); HWND hURL = GetDlgItem(hDlg, IDC_URL); int len = GetWindowTextLength(hURL); if (This && len > 0) { TCHAR* url = (TCHAR*)Alloc((len+1)*sizeof(TCHAR)); if (url) { len = GetWindowText(hURL, url, len+1); // Check if url contains "local://" at the beginning. const char* cheme = LOCAL_FILE_SCHEME; // Boolean indicating does url contain local file cheme BOOL match = TRUE; for(int k=0;k<strlen(cheme);k++){ TCHAR c_cheme=cheme[k]; TCHAR c_url=url[k]; if(c_url != c_cheme) { match = FALSE; break; } } // Launch file with the SDK launcher local cheme was found. // otherwice launch url in browser. if(match==TRUE) { TCHAR* fname=url; fname += strlen(cheme); This->iEcmtMenubar->LoadFile( This->iDefaultBrowser, fname); fname=NULL; } else {//Else launch file in browser: This->iEcmtMenubar->LaunchBrowser( This->iDefaultBrowser, url); #ifdef HAVE_WLIB // Update the URL history. First, remove duplicates. TRACE("ECMTMENUBAR: updating URL history...\n"); int i, n = ComboBox_GetCount(hURL); int bufsize = 0; TCHAR* buf = NULL; for (i=n-1; i>=0; i--) { len = ComboBox_GetLBTextLen(hURL,i); if (len >= bufsize) { Free(buf); bufsize = len+1; buf = (TCHAR*)Alloc(bufsize*sizeof(TCHAR)); if (!buf) break; } buf[0] = 0; ComboBox_GetLBText(hURL, i, buf); if (_tcscmp(buf, url) == 0) { TRACE1("ECMTMENUBAR: duplicate at %d\n",i); ComboBox_DeleteString(hURL, i); } } // Insert new item, recalculate number of items ComboBox_InsertString(hURL, 0, url); n = ComboBox_GetCount(hURL); Free(buf); // Delete extra items from the bottom int extra = n - KMaxLoadHistory; for (i=0; i<extra; i++) { ComboBox_DeleteString(hURL, n-i-1); } // Save the history RegMsz * msz = REGMSZ_Create(); if (msz) { TRACE("ECMTMENUBAR: collecting history\n"); char* buf2 = NULL; bufsize = 0; n = ComboBox_GetCount(hURL); for (i=0; i<n; i++) { len = ComboBox_GetLBTextLen(hURL,i); if (len >= bufsize) { Free(buf2); bufsize = len+1; buf2 = (char*)Alloc(bufsize); if (!buf2) break; } buf2[0] = 0; SendMessageA(hURL,CB_GETLBTEXT,i,(LPARAM)buf2); TRACE1(" %s\n",buf2); if (buf2[0]) REGMSZ_Add(msz, buf2); } HKEY key = REG_OpenCreateKey(HKCU, gRegPath); if (key) { TRACE("ECMTMENUBAR: saving history\n"); REG_SetMsz(key, gRegLoadHistory, msz); REG_CloseKey(key); } REGMSZ_Delete(msz); Free(buf2); } #endif // HAVE_WLIB } // And finally free memory Free(url); } } } // Fall through case IDCANCEL: EndDialog(hDlg, wParam); return TRUE; default: return FALSE; } default: return FALSE; } }
void LZ4CompressStream::Co(bool b) { FlushOut(); concurrent = b; Alloc(); }
Burger::Decompress16BitLEAudio * BURGER_API Burger::Decompress16BitLEAudio::New(void) { // Allocate the memory return new (Alloc(sizeof(Decompress16BitLEAudio))) Decompress16BitLEAudio(); }
/***************************************************************************** // void * malloc(size_t); *****************************************************************************/ void *_NW_malloc( size_t size ) { void * p = Alloc( size, AllocRTag); return p; }
void wxArrayString::reserve(size_t nSize) { Alloc(nSize); }
/*********************************************************************** * UpDownWndProc */ static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr (hwnd); static const WCHAR themeClass[] = {'S','p','i','n',0}; HTHEME theme; TRACE("hwnd=%p msg=%04x wparam=%08lx lparam=%08lx\n", hwnd, message, wParam, lParam); if (!infoPtr && (message != WM_CREATE)) return DefWindowProcW (hwnd, message, wParam, lParam); switch(message) { case WM_CREATE: infoPtr = Alloc (sizeof(UPDOWN_INFO)); SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr); /* initialize the info struct */ infoPtr->Self = hwnd; infoPtr->Notify = ((LPCREATESTRUCTW)lParam)->hwndParent; infoPtr->dwStyle = ((LPCREATESTRUCTW)lParam)->style; infoPtr->AccelCount = 0; infoPtr->AccelVect = 0; infoPtr->AccelIndex = -1; infoPtr->CurVal = 0; infoPtr->MinVal = 100; infoPtr->MaxVal = 0; infoPtr->Base = 10; /* Default to base 10 */ infoPtr->Buddy = 0; /* No buddy window yet */ infoPtr->Flags = 0; /* And no flags */ SetWindowLongW (hwnd, GWL_STYLE, infoPtr->dwStyle & ~WS_BORDER); /* Do we pick the buddy win ourselves? */ if (infoPtr->dwStyle & UDS_AUTOBUDDY) UPDOWN_SetBuddy (infoPtr, GetWindow (hwnd, GW_HWNDPREV)); OpenThemeData (hwnd, themeClass); TRACE("UpDown Ctrl creation, hwnd=%p\n", hwnd); break; case WM_DESTROY: Free (infoPtr->AccelVect); if(infoPtr->Buddy) RemovePropW(infoPtr->Buddy, BUDDY_UPDOWN_HWND); Free (infoPtr); SetWindowLongPtrW (hwnd, 0, 0); theme = GetWindowTheme (hwnd); CloseThemeData (theme); TRACE("UpDown Ctrl destruction, hwnd=%p\n", hwnd); break; case WM_ENABLE: if (wParam) { infoPtr->dwStyle &= ~WS_DISABLED; } else { infoPtr->dwStyle |= WS_DISABLED; UPDOWN_CancelMode (infoPtr); } InvalidateRect (infoPtr->Self, NULL, FALSE); break; case WM_STYLECHANGED: if (wParam == GWL_STYLE) { infoPtr->dwStyle = ((LPSTYLESTRUCT)lParam)->styleNew; InvalidateRect (infoPtr->Self, NULL, FALSE); } break; case WM_THEMECHANGED: theme = GetWindowTheme (hwnd); CloseThemeData (theme); OpenThemeData (hwnd, themeClass); InvalidateRect (hwnd, NULL, FALSE); break; case WM_TIMER: /* is this the auto-press timer? */ if(wParam == TIMER_AUTOPRESS) { KillTimer(hwnd, TIMER_AUTOPRESS); infoPtr->Flags &= ~(FLAG_PRESSED | FLAG_ARROW); InvalidateRect(infoPtr->Self, NULL, FALSE); } /* if initial timer, kill it and start the repeat timer */ if(wParam == TIMER_AUTOREPEAT) { int temp; KillTimer(hwnd, TIMER_AUTOREPEAT); /* if no accel info given, used default timer */ if(infoPtr->AccelCount==0 || infoPtr->AccelVect==0) { infoPtr->AccelIndex = -1; temp = REPEAT_DELAY; } else { infoPtr->AccelIndex = 0; /* otherwise, use it */ temp = infoPtr->AccelVect[infoPtr->AccelIndex].nSec * 1000 + 1; } SetTimer(hwnd, TIMER_ACCEL, temp, 0); } /* now, if the mouse is above us, do the thing...*/ if(infoPtr->Flags & FLAG_MOUSEIN) { int temp; temp = infoPtr->AccelIndex == -1 ? 1 : infoPtr->AccelVect[infoPtr->AccelIndex].nInc; UPDOWN_DoAction(infoPtr, temp, infoPtr->Flags & FLAG_ARROW); if(infoPtr->AccelIndex != -1 && infoPtr->AccelIndex < infoPtr->AccelCount-1) { KillTimer(hwnd, TIMER_ACCEL); infoPtr->AccelIndex++; /* move to the next accel info */ temp = infoPtr->AccelVect[infoPtr->AccelIndex].nSec * 1000 + 1; /* make sure we have at least 1ms intervals */ SetTimer(hwnd, TIMER_ACCEL, temp, 0); } } break; case WM_CANCELMODE: return UPDOWN_CancelMode (infoPtr); case WM_LBUTTONUP: if (GetCapture() != infoPtr->Self) break; if ( (infoPtr->Flags & FLAG_MOUSEIN) && (infoPtr->Flags & FLAG_ARROW) ) { SendMessageW( infoPtr->Notify, (infoPtr->dwStyle & UDS_HORZ) ? WM_HSCROLL : WM_VSCROLL, MAKELONG(SB_ENDSCROLL, infoPtr->CurVal), (LPARAM)hwnd); if (UPDOWN_IsBuddyEdit(infoPtr)) SendMessageW(infoPtr->Buddy, EM_SETSEL, 0, MAKELONG(0, -1)); } UPDOWN_CancelMode(infoPtr); break; case WM_LBUTTONDOWN: case WM_MOUSEMOVE: case WM_MOUSELEAVE: if(UPDOWN_IsEnabled(infoPtr)) UPDOWN_HandleMouseEvent (infoPtr, message, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam)); break; case WM_MOUSEWHEEL: UPDOWN_MouseWheel(infoPtr, wParam); break; case WM_KEYDOWN: if((infoPtr->dwStyle & UDS_ARROWKEYS) && UPDOWN_IsEnabled(infoPtr)) return UPDOWN_KeyPressed(infoPtr, (int)wParam); break; case WM_PRINTCLIENT: case WM_PAINT: return UPDOWN_Paint (infoPtr, (HDC)wParam); case UDM_GETACCEL: if (wParam==0 && lParam==0) return infoPtr->AccelCount; if (wParam && lParam) { int temp = min(infoPtr->AccelCount, wParam); memcpy((void *)lParam, infoPtr->AccelVect, temp*sizeof(UDACCEL)); return temp; } return 0; case UDM_SETACCEL: { unsigned temp; TRACE("UDM_SETACCEL\n"); if(infoPtr->AccelVect) { Free (infoPtr->AccelVect); infoPtr->AccelCount = 0; infoPtr->AccelVect = 0; } if(wParam==0) return TRUE; infoPtr->AccelVect = Alloc (wParam*sizeof(UDACCEL)); if(infoPtr->AccelVect == 0) return FALSE; memcpy(infoPtr->AccelVect, (void*)lParam, wParam*sizeof(UDACCEL)); infoPtr->AccelCount = wParam; for (temp = 0; temp < wParam; temp++) TRACE("%d: nSec %u nInc %u\n", temp, infoPtr->AccelVect[temp].nSec, infoPtr->AccelVect[temp].nInc); return TRUE; } case UDM_GETBASE: return infoPtr->Base; case UDM_SETBASE: TRACE("UpDown Ctrl new base(%ld), hwnd=%p\n", wParam, hwnd); if (wParam==10 || wParam==16) { WPARAM temp = infoPtr->Base; infoPtr->Base = wParam; return temp; } break; case UDM_GETBUDDY: return (LRESULT)infoPtr->Buddy; case UDM_SETBUDDY: return (LRESULT)UPDOWN_SetBuddy (infoPtr, (HWND)wParam); case UDM_GETPOS: { int temp = UPDOWN_GetBuddyInt (infoPtr); return MAKELONG(infoPtr->CurVal, temp ? 0 : 1); } case UDM_SETPOS: { int temp = (short)LOWORD(lParam); TRACE("UpDown Ctrl new value(%d), hwnd=%p\n", temp, hwnd); if(!UPDOWN_InBounds(infoPtr, temp)) { if(temp < infoPtr->MinVal) temp = infoPtr->MinVal; if(temp > infoPtr->MaxVal) temp = infoPtr->MaxVal; } wParam = infoPtr->CurVal; infoPtr->CurVal = temp; UPDOWN_SetBuddyInt (infoPtr); return wParam; /* return prev value */ } case UDM_GETRANGE: return MAKELONG(infoPtr->MaxVal, infoPtr->MinVal); case UDM_SETRANGE: /* we must have: */ infoPtr->MaxVal = (short)(lParam); /* UD_MINVAL <= Max <= UD_MAXVAL */ infoPtr->MinVal = (short)HIWORD(lParam); /* UD_MINVAL <= Min <= UD_MAXVAL */ /* |Max-Min| <= UD_MAXVAL */ TRACE("UpDown Ctrl new range(%d to %d), hwnd=%p\n", infoPtr->MinVal, infoPtr->MaxVal, hwnd); break; case UDM_GETRANGE32: if (wParam) *(LPINT)wParam = infoPtr->MinVal; if (lParam) *(LPINT)lParam = infoPtr->MaxVal; break; case UDM_SETRANGE32: infoPtr->MinVal = (INT)wParam; infoPtr->MaxVal = (INT)lParam; if (infoPtr->MaxVal <= infoPtr->MinVal) infoPtr->MaxVal = infoPtr->MinVal + 1; TRACE("UpDown Ctrl new range(%d to %d), hwnd=%p\n", infoPtr->MinVal, infoPtr->MaxVal, hwnd); break; case UDM_GETPOS32: if ((LPBOOL)lParam != NULL) *((LPBOOL)lParam) = TRUE; return infoPtr->CurVal; case UDM_SETPOS32: { int temp; if(!UPDOWN_InBounds(infoPtr, (int)lParam)) { if((int)lParam < infoPtr->MinVal) lParam = infoPtr->MinVal; if((int)lParam > infoPtr->MaxVal) lParam = infoPtr->MaxVal; } temp = infoPtr->CurVal; /* save prev value */ infoPtr->CurVal = (int)lParam; /* set the new value */ UPDOWN_SetBuddyInt (infoPtr); return temp; /* return prev value */ } case UDM_GETUNICODEFORMAT: /* we lie a bit here, we're always using Unicode internally */ return infoPtr->UnicodeFormat; case UDM_SETUNICODEFORMAT: { /* do we really need to honour this flag? */ int temp = infoPtr->UnicodeFormat; infoPtr->UnicodeFormat = (BOOL)wParam; return temp; } default: if ((message >= WM_USER) && (message < WM_APP) && !COMCTL32_IsReflectedMessage(message)) ERR("unknown msg %04x wp=%04lx lp=%08lx\n", message, wParam, lParam); return DefWindowProcW (hwnd, message, wParam, lParam); } return 0; }
void Burger::Filename::SetFromNative(const char *pInput) { Clear(); if (!pInput || !pInput[0]) { // No directory at all? pInput = "."; // Just get the current directory } // First thing, convert it to UTF16 WCHAR InputPath[512]; WCHAR *pInputPath; WordPtr uInputLength = UTF16::FromUTF8(reinterpret_cast<Word16 *>(InputPath),sizeof(InputPath),pInput); if (uInputLength>=sizeof(InputPath)) { pInputPath = static_cast<WCHAR *>(Alloc(uInputLength+2)); if (!pInputPath) { return; } uInputLength = UTF16::FromUTF8(reinterpret_cast<Word16 *>(pInputPath),uInputLength+2,pInput); } else { pInputPath = InputPath; } // Now that it's UTF16, let's have Windows expand it WCHAR ExpandedPath[512]; WCHAR *pExpanded; // Have windows expand it out WordPtr uExpandedLength = GetFullPathNameW(pInputPath,sizeof(ExpandedPath)/2,ExpandedPath,NULL)*2; if (uExpandedLength>=sizeof(ExpandedPath)) { pExpanded = static_cast<WCHAR *>(Alloc(uExpandedLength+2)); if (pExpanded) { uExpandedLength = GetFullPathNameW(pInputPath,static_cast<DWORD>((uExpandedLength+2)/2),pExpanded,NULL); } } else { pExpanded = ExpandedPath; } // I don't need the original anymore if (pInputPath!=InputPath) { Free(pInputPath); } // Was there a memory error above? if (!pExpanded) { return; // Fudge } // How long would the string be if it was UTF8? WordPtr uOutputLength = UTF8::FromUTF16(NULL,0,reinterpret_cast<Word16*>(pExpanded))+6; char *pWork = m_Filename; if (uOutputLength>=BUFFERSIZE) { pWork = static_cast<char *>(Alloc(uOutputLength)); if (!pWork) { if (pExpanded!=ExpandedPath) { Free(pExpanded); } return; } } m_pFilename = pWork; WCHAR *pSrc = pExpanded; char *pOutput = pWork; // Network name? if ((uExpandedLength>=(2*2)) && pSrc[0]=='\\' && pSrc[1]=='\\') { pOutput[0] = ':'; // Leading colon ++pOutput; // Accept it pSrc+=2; // Only return 1 colon } else { Word uTemp = static_cast<Word>(pSrc[0]); // Get the drive letter if ((uTemp>='a') && (uTemp<('z'+1))) { // Upper case uTemp &= 0xDF; } uTemp = uTemp-'A'; pSrc += 3; // Accept the "C:\" // At this point I have the drive number, create the drive number prefix pOutput[0] = '.'; // .D2 for C: pOutput[1] = 'D'; pOutput = NumberToAscii(&pOutput[2],static_cast<Word32>(uTemp),NOENDINGNULL); pOutput[0] = ':'; // Append a colon ++pOutput; } // Append the filename to output and convert from UTF16 to UTF8 UTF8::FromUTF16(pOutput,uOutputLength-(pOutput-pWork),reinterpret_cast<Word16*>(pSrc)); if (pExpanded!=ExpandedPath) { Free(pExpanded); } Word uTemp2 = reinterpret_cast<Word8 *>(pOutput)[0]; if (uTemp2) { do { if (uTemp2=='\\') { // Convert directory holders uTemp2 = ':'; // To generic paths } pOutput[0] = static_cast<char>(uTemp2); // Save char ++pOutput; uTemp2 = pOutput[0]; // Next char } while (uTemp2); // Still more? } // The wrap up... // Make sure it's appended with a colon if (pOutput[-1]!=':') { // Last char a colon? pOutput[0] = ':'; // End with a colon! pOutput[1] = 0; } }
int GaussianMixture::Load(string nomfic) { int ddim,nbgauss; ifstream fichier; double* mm; double* cc; char pattern[256]; /* ouverture */ fichier.open(nomfic.c_str(), ios::in); if(fichier.bad()) return 0; /* Lecture du nombre de gaussiennes */ FindStr(fichier,"<nb>"); if(fichier.eof()) {cout << dispdec << "|ERROR|--> GaussianMixture (Load) \t:\t <nb> not found" << endl; return 0;} fichier >> nbgauss; /* Lecture de la dimension des gaussiennes */ FindStr(fichier,"<dim>"); if(fichier.eof()) {cout << dispdec << "|ERROR|--> GaussianMixture (Load) \t:\t <dim> not found" << endl; return 0;} fichier >> ddim; this->dim = ddim; /* Allocations d'un melange de gaussiennes sans init */ Alloc(nbgauss,this->dim,NULL,NULL); /* Allocation de moyenne et covariance temp */ mm = new double[this->dim]; cc = new double[this->dim*this->dim]; /*Lecture des gausiennes une par une */ for(int n=0;n<nbgauss;n++) { /* Lecture moyenne */ sprintf(pattern,"<mean_%d>",n); FindStr(fichier,pattern); if(fichier.eof()) {cout << dispdec << "|ERROR|--> GaussianMixture (Load) \t:\t " << pattern << " not found" << endl; return 0;} for(int i=0;i<this->dim;i++) fichier >> mm[i]; /* Lecture covariance */ sprintf(pattern,"<cov_%d>",n); FindStr(fichier,pattern); if(fichier.eof()) {cout << dispdec << "|ERROR|--> GaussianMixture (Load) \t:\t " << pattern << " not found" << endl; return 0;} for(int i=0;i<this->dim*this->dim;i++) fichier >> cc[i]; /* Lecture coefficient */ // sprintf(pattern,"<coeff_%d>",n); // FindStr(fichier,pattern); // if(fichier.eof()) {cout << "|ERROR|--> GaussianMixture (Load) \t:\t " << pattern << " not found" << endl; return 0;} // fichier >> coeff[i]; /* Init de la gaussienne i */ glist[n]->Init(mm,cc); } fichier.close(); delete [] mm; delete [] cc; return 1; }