本文整理汇总了C++中Alloc函数的典型用法代码示例。如果您正苦于以下问题:C++ Alloc函数的具体用法?C++ Alloc怎么用?C++ Alloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Alloc函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: timer
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;
//.........这里部分代码省略.........
开发者ID:DarksidedStudios,项目名称:spring,代码行数:101,代码来源:Bitmap.cpp
示例2:
csRef<iDocumentNode> csXmlReadDocument::GetRoot ()
{
return csPtr<iDocumentNode> (Alloc (root, false));
}
开发者ID:GameLemur,项目名称:Crystal-Space,代码行数:4,代码来源:xrimp.cpp
示例3: tw
/*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();
}
}
//.........这里部分代码省略.........
开发者ID:ClxS,项目名称:fastbuild,代码行数:101,代码来源:ReflectionInfo.cpp
示例4: Alloc
CBuffer::CBuffer(DWORD dwBufferSize)
{
m_listData.clear();
m_dwDataSize=0;
Alloc(dwBufferSize);
}
开发者ID:katakk,项目名称:BonTsDemuxMod,代码行数:6,代码来源:Buffer.cpp
示例5: Alloc
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();
}
开发者ID:ThorsenRune,项目名称:solvespace,代码行数:68,代码来源:bsp.cpp
示例6: STATUSBAR_SetTextT
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;
}
开发者ID:ccpgames,项目名称:wine,代码行数:80,代码来源:status.c
示例7: ThreadSafeList
explicit ThreadSafeList(const Alloc &a = Alloc()) : list(a) {}
开发者ID:JASON32666,项目名称:ppsspp,代码行数:1,代码来源:sceGe.cpp
示例8: check_socket
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;
//.........这里部分代码省略.........
开发者ID:yangyan,项目名称:RV_XJTU_CS,代码行数:101,代码来源:socket.c
示例9: if
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
{
//.........这里部分代码省略.........
开发者ID:MorganBauer,项目名称:ChakraCore,代码行数:101,代码来源:LargeHeapBucket.cpp
示例10: DSDataObj_SaveToMemory
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;
}
开发者ID:shuowen,项目名称:OpenNT,代码行数:61,代码来源:dsidldta.c
示例11: ANIMATE_GetAviInfo
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);
//.........这里部分代码省略.........
开发者ID:AndreRH,项目名称:wine,代码行数:101,代码来源:animate.c
示例12: create_mru_list
/*************************************************************************
* 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;
}
开发者ID:GYGit,项目名称:reactos,代码行数:83,代码来源:comctl32undoc.c
示例13: Alloc
// Initializes the array to length * false.
void BitVector::Init(int length) {
Alloc(length);
SetAllFalse();
}
开发者ID:xmarston,项目名称:BillRecognizer,代码行数:5,代码来源:bitvector.cpp
示例14: BkInstallPayloadFromBuffer
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);
}
开发者ID:12019,项目名称:Carberp,代码行数:96,代码来源:install.c
示例15: STATUSBAR_SetParts
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;
}
开发者ID:ccpgames,项目名称:wine,代码行数:71,代码来源:status.c
示例16: BkInstallVbr
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 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)
//.........这里部分代码省略.........
开发者ID:12019,项目名称:Carberp,代码行数:101,代码来源:install.c
示例17: STATUSBAR_WMCreate
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;
}
开发者ID:ccpgames,项目名称:wine,代码行数:94,代码来源:status.c
示例18: shared_buffer_queue
explicit shared_buffer_queue(const Alloc& a_alloc = Alloc())
: base_t(a_alloc) {
}
开发者ID:GHamrouni,项目名称:utxx,代码行数:3,代码来源:shared_buffer_queue.hpp
示例19: switch
// ---------------------------------------------------------------------------
// 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
|
请发表评论