本文整理汇总了C++中HeapCreate函数的典型用法代码示例。如果您正苦于以下问题:C++ HeapCreate函数的具体用法?C++ HeapCreate怎么用?C++ HeapCreate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了HeapCreate函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: _tmain
int _tmain(int argc, _TCHAR* argv[])
{
HANDLE hHeap = HeapCreate(HEAP_NO_SERIALIZE, PAGE_SIZE*10, PAGE_SIZE*100);
int* pArr = (int* ) HeapAlloc(hHeap, 0, sizeof(int) * 30);
for(int i = 0 ; i < 10 ; ++i)
{
if(i % 5 == 0)
printf_s("\n");
pArr[i] = (i + 1) * 100;
}
for(int i = 0 ; i < 30 ; ++i)
{
if(i % 5 == 0)
printf_s("\n");
printf_s("%d ", pArr[i]);
}
HeapFree(hHeap, 0, pArr);
HeapDestroy(hHeap);
getchar();
return 0;
}
开发者ID:zrma,项目名称:OSWindows,代码行数:26,代码来源:DynamicHeap.cpp
示例2: main
int main(int argc, char *argv[]){
void *test;
HGLOBAL hgtest;
HLOCAL hltest;
HANDLE heapcreate;
LPVOID hptest;
//LPVOID hvtest;
test = malloc(100);
memset(test,'a',100);
zfree(test);
hgtest = GlobalAlloc(GMEM_FIXED,100);
memset(hgtest,'a',100);
zGlobalFree(hgtest);
hltest = LocalAlloc(LMEM_FIXED,100);
memset(hltest,'a',100);
zLocalFree(hltest);
heapcreate = HeapCreate(0,100,100);
hptest = HeapAlloc(heapcreate,HEAP_ZERO_MEMORY,100);
memset(hptest,'a',100);
zHeapFree(heapcreate,0,hptest);
HeapDestroy(heapcreate);
/* yet to implement
hvtest = VirtualAlloc(NULL,100,MEM_COMMIT,PAGE_READWRITE);
memset(hvtest,'a',100);
zVirtualFree(hvtest,100,MEM_RELEASE);
return 0;
*/
}
开发者ID:DiabloHorn,项目名称:zmem,代码行数:32,代码来源:zmem_test.c
示例3: HeapCreate
BOOL
LongBinary::SetBinarySize(DWORD sizeNew, void* lpDataCopy){
if (m_hMemory == NULL){ // Allocate
m_pBuffer = NULL;
if (sizeNew == 0)
return TRUE;
m_hMemory = HeapCreate(0L, sizeNew, 0L);
ASSERT(m_hMemory);
m_pBuffer = HeapAlloc(m_hMemory, 0L, sizeNew);
m_dwSize = sizeNew;
}
else{ // Reallocate
if (sizeNew > m_dwSize){
// Allocate or realocate memory . #####
m_pBuffer = HeapReAlloc(m_hMemory, 0L, m_pBuffer, sizeNew);
m_dwSize = sizeNew;
}
else
if (sizeNew == 0){
HeapFree(m_hMemory, 0L, m_pBuffer);
HeapDestroy(m_hMemory);
m_pBuffer = NULL;
m_hMemory = NULL;
m_dwSize = 0;
}
}
if( lpDataCopy != NULL && m_hMemory ){
memcpy(m_pBuffer, lpDataCopy, sizeNew);
}
return TRUE;
}
开发者ID:zqrtalent,项目名称:MercuryUI,代码行数:32,代码来源:PlatformLongBinary.cpp
示例4: Unitialize
BOOL CHeapAllocator::Initialize(SIZE_T dwInitSize)
{
Unitialize();
m_hHeap = HeapCreate(0,dwInitSize,0);
// Jie JIAN changed @ 2007-12-28
// use LFH if possible
typedef BOOL (WINAPI *PFN_HEAPSETINFORMATION)(HANDLE, HEAP_INFORMATION_CLASS, PVOID, SIZE_T);
HMODULE hKernel32 = LoadLibraryW( L"kernel32.dll" );
if ( NULL != hKernel32 )
{
PFN_HEAPSETINFORMATION pfnHeapSetInformation =
reinterpret_cast<PFN_HEAPSETINFORMATION>(
GetProcAddress(hKernel32, "HeapSetInformation")
);
if ( NULL != pfnHeapSetInformation )
{
ULONG ulHeapInformation = 2;
(*pfnHeapSetInformation)( m_hHeap,
HeapCompatibilityInformation,
&ulHeapInformation,
sizeof(ULONG) );
}
FreeLibrary(hKernel32);
}
return TRUE;
}
开发者ID:sharkka,项目名称:xzcapture,代码行数:32,代码来源:HeapAllocator.cpp
示例5: ProcessAttach
// TODO: I should probably move all initalization inside the thread
// We should minimize the amount of work done in DLL_PROCESS_ATTACH as per
// http://blogs.msdn.com/b/oleglv/archive/2003/10/24/56141.aspx
static BOOL ProcessAttach()
{
lf("memtrace.dll: ProcessAttach()");
if (!OpenPipe()) {
lf("memtrace.dll: couldn't open pipe");
return FALSE;
} else {
lf("memtrace.dll: opened pipe");
}
gHeap = HeapCreate(0, 0, 0);
if (!gHeap) {
lf("memtrace.dll: failed to create heap");
return FALSE;
}
InitializeCriticalSection(&gMemMutex);
gSendThreadEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
if (!gSendThreadEvent) {
lf("memtrace.dll: couldn't create gSendThreadEvent");
return FALSE;
}
gSendThread = CreateThread(NULL, 0, DataSendThreadProc, NULL, 0, 0);
if (!gSendThread) {
lf("memtrace.dll: couldn't create gSendThread");
return FALSE;
}
InstallHooks();
return TRUE;
}
开发者ID:BianChengNan,项目名称:sumatrapdf,代码行数:33,代码来源:MemTraceDll.cpp
示例6: tb_native_memory_init
/* //////////////////////////////////////////////////////////////////////////////////////
* implementation
*/
tb_bool_t tb_native_memory_init()
{
// enter
tb_spinlock_enter_without_profiler(&g_lock);
// done
tb_bool_t ok = tb_false;
do
{
// have been inited?
tb_check_break_state(!g_heap, ok, tb_true);
// make heap
g_heap = (tb_handle_t)HeapCreate(0, 0, 0);
tb_check_break(g_heap);
// ok
ok = tb_true;
} while (0);
// leave
tb_spinlock_leave(&g_lock);
// ok?
return ok;
}
开发者ID:siwuxian,项目名称:xmake,代码行数:30,代码来源:memory.c
示例7: _win32_initHeap
inline static void _win32_initHeap( void )
{
g_privateHeap = HeapCreate( 0, 0, 0 );
unsigned int info = 0;
HeapSetInformation( g_privateHeap, HeapCompatibilityInformation, &info, sizeof(info) );
}
开发者ID:qaisjp,项目名称:green-candy,代码行数:7,代码来源:dbgheap.cpp
示例8: PatchMW2_StringList
void PatchMW2_StringList()
{
slHashMap.set_empty_key("*DUMMYDUMMY*");
slHashMap.set_deleted_key("*DUMMYDUMM*");
call(0x4D2280, SL_Init, PATCH_JUMP);
call(0x436B40, SL_GetStringOfSize, PATCH_JUMP);
call(0x4EC1D0, SL_ConvertToString_, PATCH_JUMP);
call(0x61BCB0, FindStringOfSize, PATCH_JUMP);
call(0x469D80, SL_ConvertFromString, PATCH_JUMP);
call(0x4D9B00, SL_AddRefToString, PATCH_JUMP);
call(0x4F1500, SL_RemoveRefToStringOfSize, PATCH_JUMP);
call(0x47CD70, SL_RemoveRefToString, PATCH_JUMP);
call(0x417730, Scr_SetString, PATCH_JUMP);
call(0x4401E0, SL_GetStringLen, PATCH_JUMP);
call(0x40C050, SL_TransferRefToUser, PATCH_JUMP);
call(0x4B4310, SL_AddUser, PATCH_JUMP);
call(0x430510, SL_ConvertToLowercase, PATCH_JUMP);
call(0x4F46D0, SL_ShutdownSystem, PATCH_JUMP);
call(0x4A44A0, SL_TransferSystem, PATCH_JUMP);
stringHeap = HeapCreate(0, 1024 * 1024, 0);
// path_node_constant_t marking function; has some terrible string references
*(BYTE*)0x4F74B0 = 0xC3;
}
开发者ID:Call-of-Duty-Scripts,项目名称:fourdeltaone,代码行数:26,代码来源:PatchMW2StringList.cpp
示例9: hpgs_init
/*! This function has to be called before using any other
function of hpgs. It defines the path, where additional
files such as the truetype files for HPGL files or plugins
are stored.
Truetype fonts are searched in the path <prefix>/share/hpgs
The path is internally duplicated using \c strdup.
*/
void hpgs_init(const char *path)
{
int l;
hpgs_reader_prefix = strdup(path);
if (!hpgs_reader_prefix) return;
// strip off trailing directory separators.
l = strlen(hpgs_reader_prefix);
if (l && hpgs_reader_prefix[l-1] == HPGS_PATH_SEPARATOR)
hpgs_reader_prefix[l-1] = '\0';
#ifdef WIN32
hHeap = HeapCreate(0,4096,128*1024);
tls_handle = TlsAlloc();
#else
pthread_key_create (&key,free);
#endif
#ifdef HPGS_HAVE_GETTEXT
hpgs_i18n_init();
#endif
hpgs_font_init();
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:34,代码来源:hpgsglobal.c
示例10: m_heap
CLrpHeap::CLrpHeap() : m_heap(HeapCreate(0, 0, 0))
{
if (nullptr == m_heap)
{
throw runtime_error("Couldn't create a new memory heap");
}
}
开发者ID:ifzz,项目名称:FDK,代码行数:7,代码来源:LrpHeap.cpp
示例11: MH_Initialize
//-------------------------------------------------------------------------
MH_STATUS WINAPI MH_Initialize(VOID)
{
MH_STATUS status = MH_OK;
EnterSpinLock();
if (g_hHeap == NULL)
{
g_hHeap = HeapCreate(0, 0, 0);
if (g_hHeap != NULL)
{
// Initialize the internal function buffer.
InitializeBuffer();
}
else
{
status = MH_ERROR_MEMORY_ALLOC;
}
}
else
{
status = MH_ERROR_ALREADY_INITIALIZED;
}
LeaveSpinLock();
return status;
}
开发者ID:peterdocter,项目名称:minhook,代码行数:29,代码来源:hook.c
示例12: get_tls_heap
HANDLE get_tls_heap()
{
if (local_heap_tls == 0)
{
local_heap_tls = TlsAlloc();
if (local_heap_tls == 0)
{
return (NULL);
}
}
void* tls_val = TlsGetValue(local_heap_tls);
if (tls_val == NULL)
{
HANDLE heap = HeapCreate(HEAP_NO_SERIALIZE, 0, 0);
if (heap == 0)
{
return (NULL);
}
tls_val = (void*)heap;
TlsSetValue(local_heap_tls, tls_val);
}
return (HANDLE)tls_val;
}
开发者ID:huangqiheng,项目名称:andpack,代码行数:26,代码来源:xml_in_section.c
示例13: InitModuleNames
int InitModuleNames(void)
{
struct DBModuleName *dbmn;
DWORD ofsThis;
int nameLen;
char *mod;
hModHeap=HeapCreate(0,0,0);
lMods.sortFunc=ModCompare;
lMods.increment=50;
lOfs.sortFunc=OfsCompare;
lOfs.increment=50;
ofsThis=dbHeader.ofsFirstModuleName;
dbmn=(struct DBModuleName*)DBRead(ofsThis,sizeof(struct DBModuleName),NULL);
while(ofsThis) {
if(dbmn->signature!=DBMODULENAME_SIGNATURE) DatabaseCorruption(NULL);
nameLen=dbmn->cbName;
mod = (char*)HeapAlloc(hModHeap,0,nameLen+1);
CopyMemory(mod,DBRead(ofsThis+offsetof(struct DBModuleName,name),nameLen,NULL),nameLen);
mod[nameLen] = 0;
AddToList(mod, nameLen, ofsThis);
ofsThis=dbmn->ofsNext;
dbmn=(struct DBModuleName*)DBRead(ofsThis,sizeof(struct DBModuleName),NULL);
}
CreateServiceFunction(MS_DB_MODULES_ENUM,EnumModuleNames);
return 0;
}
开发者ID:raoergsls,项目名称:miranda,代码行数:32,代码来源:dbmodulechain.c
示例14: WinAPIOverride32Init
BOOL WinAPIOverride32Init(HINSTANCE hInst) {
TCHAR psz[MAX_PATH+32];
TCHAR pszPID[32];
SYSTEM_INFO siSysInfo;
DisableThreadLibraryCalls(hInst);
dwCurrentProcessID = GetCurrentProcessId();
wsprintf(pszPID, "0x%X", dwCurrentProcessID);
lstrcpy(psz, APIOVERRIDE_MUTEX);
lstrcat(psz, pszPID);
pSingleInstance = new CSingleInstance(psz);
if (pSingleInstance->IsAnotherInstanceRunning()) {
delete pSingleInstance;
return FALSE;
}
GetSystemInfo(&siSysInfo);
dwSystemPageSize = siSysInfo.dwPageSize;
ApiOverrideHeap = HeapCreate(HEAP_CREATE_ENABLE_EXECUTE | HEAP_GROWABLE, dwSystemPageSize, 0);
pLinkListAPIInfos = new CLinkList(sizeof(API_INFO));
pLinkListAPIInfos->SetHeap(ApiOverrideHeap);
return TRUE;
}
开发者ID:KGE-INC,项目名称:vdubauo,代码行数:29,代码来源:wao.cpp
示例15: CreateMutex
Thunk32Base::Thunk32Base()
{
// Double checked locking, guaranteed by Acquire/Release-semantics in Microsoft's
// volatile-implementation.
if(bytecodeHeap == NULL)
{
hMutex = CreateMutex(NULL, TRUE, NULL);
while (hMutex == (HANDLE)NULL || hMutex == (HANDLE)ERROR_ALREADY_EXISTS || hMutex == (HANDLE)ERROR_ACCESS_DENIED) {
Sleep(1000);
}
if(bytecodeHeap == NULL)
{
bytecodeHeap = HeapCreate(HEAP_CREATE_ENABLE_EXECUTE, 0, 0);
if(bytecodeHeap == NULL)
{
throw std::exception("Heap creation failed!");
}
// Schedule the heap to be destroyed when the application terminates.
// Until then, it will manage its own size.
atexit(cleanupHeap);
}
}
bytecode = reinterpret_cast<Bytecode*>(HeapAlloc(bytecodeHeap, 0, sizeof(Bytecode)));
if(bytecode == NULL)
{
throw std::exception("Bytecode allocation failed!");
}
new (bytecode) Bytecode;
}
开发者ID:Pritula,项目名称:CPPWndWrapper,代码行数:32,代码来源:thunk32.cpp
示例16: FAssert
//------------------------------------------------------------------------------
void CvDllGameContext::InitializeSingleton()
{
if(s_pSingleton == NULL)
{
FAssert(s_hHeap == INVALID_HANDLE_VALUE);
s_hHeap = HeapCreate(0, 0, 0);
//
// Enable the low-fragmentation heap (LFH). Starting with Windows Vista,
// the LFH is enabled by default but this call does not cause an error.
//
ULONG HeapInformation = 2; //Low Fragmentation Heap
HeapSetInformation(s_hHeap,
HeapCompatibilityInformation,
&HeapInformation,
sizeof(HeapInformation));
}
s_pSingleton = FNEW(CvDllGameContext(), c_eCiv5GameplayDLL, 0);
#if defined(CUSTOM_MODS_H)
CUSTOMLOG("%s - Startup (Version %u%s - Build %s %s%s)", MOD_DLL_NAME, MOD_DLL_VERSION_NUMBER, MOD_DLL_VERSION_STATUS, __DATE__, __TIME__, MOD_DLL_CUSTOM_BUILD_NAME);
#if defined(MOD_GLOBAL_MAX_MAJOR_CIVS)
CUSTOMLOG(" - supporting %i major civilizations", MAX_MAJOR_CIVS);
#endif
#endif
}
开发者ID:kawyua,项目名称:Community-Patch-DLL,代码行数:28,代码来源:CvDllContext.cpp
示例17: SaveDump
bool SaveDump(string fileName, DWORD ep)
{
strCurEIP = ep;
//OPENFILENAME ofn;
HANDLE hHeap, hFile;
PIMAGE_DOS_HEADER idosh;
PIMAGE_NT_HEADERS ipeh;
PIMAGE_SECTION_HEADER isech;
LPBYTE lpDumpData;
DWORD dwFrom,dwSize,dwAccBytes;
unsigned int i;
dwFrom = PEFileInfo.dwImageBase;
dwSize = PEFileInfo.dwSizeOfImage;
hHeap = HeapCreate(HEAP_NO_SERIALIZE,1,0);
lpDumpData = (LPBYTE)HeapAlloc(hHeap,HEAP_NO_SERIALIZE | HEAP_ZERO_MEMORY,dwSize);
dwSize = Readmemory(lpDumpData,dwFrom,dwSize,MM_RESTORE);
idosh = (PIMAGE_DOS_HEADER)lpDumpData;
if(idosh->e_magic != IMAGE_DOS_SIGNATURE)
{
MessageBox(0, "DUMP: 错误的DOS头(MZ)!!",PNAME,MB_OK | MB_ICONEXCLAMATION);
HeapFree(hHeap,HEAP_NO_SERIALIZE,lpDumpData);
return false;
}
ipeh = (PIMAGE_NT_HEADERS)(lpDumpData + idosh->e_lfanew);
if(ipeh->Signature != IMAGE_NT_SIGNATURE)
{
MessageBox(0, "DUMP: 错误的PE标志头!!",PNAME,MB_OK | MB_ICONEXCLAMATION);
HeapFree(hHeap,HEAP_NO_SERIALIZE,lpDumpData);
return false;
}
ipeh->FileHeader.NumberOfSections = PEFileInfo.woNumOfSect;
ipeh->OptionalHeader.ImageBase = PEFileInfo.dwImageBase;
ipeh->OptionalHeader.SizeOfImage = PEFileInfo.dwSizeOfImage;
ipeh->OptionalHeader.BaseOfCode = PEFileInfo.dwBaseOfCode;
ipeh->OptionalHeader.BaseOfData = PEFileInfo.dwBaseOfData;
ipeh->OptionalHeader.AddressOfEntryPoint = (strCurEIP - PEFileInfo.dwImageBase) ;
isech = IMAGE_FIRST_SECTION(ipeh);
if(FixSect) {
for(i=0; i<(int)PEFileInfo.woNumOfSect; i++)
{
strcpy((char *)(isech+i)->Name,(char *)(lpSectInfo+i)->byName);
(isech+i)->Misc.VirtualSize = (lpSectInfo+i)->dwVSize;
(isech+i)->VirtualAddress = (lpSectInfo+i)->dwVOffset;
(isech+i)->SizeOfRawData = (lpSectInfo+i)->dwVSize;
(isech+i)->PointerToRawData = (lpSectInfo+i)->dwVOffset;
(isech+i)->Characteristics = (lpSectInfo+i)->dwCharacteristics;
}
}
strcpy( szFileName, fileName.c_str() );
hFile = CreateFile(szFileName, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if(hFile != INVALID_HANDLE_VALUE)
{
SetFilePointer(hFile, 0, 0, FILE_BEGIN);
WriteFile(hFile, lpDumpData, dwSize, &dwAccBytes, NULL);
CloseHandle(hFile);
}
HeapFree(hHeap,HEAP_NO_SERIALIZE,lpDumpData);
return true;
}
开发者ID:int8o,项目名称:Plugme-OllyDBGv1.0,代码行数:60,代码来源:HelperFunctions.cpp
示例18: MmInitializeHeap
VOID
MmInitializeHeap(PVOID PageLookupTable)
{
TRACE("MmInitializeHeap()\n");
/* Create the default heap */
FrLdrDefaultHeap = HeapCreate(DEFAULT_HEAP_SIZE, LoaderOsloaderHeap);
ASSERT(FrLdrDefaultHeap);
/* Create a temporary heap */
FrLdrTempHeap = HeapCreate(TEMP_HEAP_SIZE, LoaderFirmwareTemporary);
ASSERT(FrLdrTempHeap);
TRACE("MmInitializeHeap() done, default heap %p, temp heap %p\n",
FrLdrDefaultHeap, FrLdrTempHeap);
}
开发者ID:killvxk,项目名称:NT_OS,代码行数:16,代码来源:heap.c
示例19: GetLastError
void *
CMemAlloc::Create(int ElSize,int NumEls,DWORD HeapFlags)
{
void *pAllocd;
m_LastErr = 0;
if(ElSize < 1) // make the initial allocation worth the exercise
ElSize = 1;
if((NumEls * ElSize) < 1024)
NumEls = (1024/ElSize) + 1;
if(m_hHeap == NULL) // create heap, or reuse if one already created
{
if((m_hHeap = HeapCreate(HeapFlags,ElSize * NumEls,0))==NULL)
{
m_LastErr = GetLastError();
return(NULL);
}
pAllocd = HeapAlloc(m_hHeap,HeapFlags,ElSize*NumEls);
}
else
pAllocd = HeapReAlloc(m_hHeap,0,m_pAllocd,ElSize*NumEls);
if(pAllocd != NULL)
{
m_ElSize = ElSize;
m_NumEls = NumEls;
m_pAllocd = pAllocd;
}
else
m_LastErr = GetLastError();
return(pAllocd);
}
开发者ID:ste69r,项目名称:Biokanga,代码行数:30,代码来源:MemAlloc.cpp
示例20: DllMain
////////////////////////////////////////////////////////////////////////
// DllMain -- OCX Main Entry
//
//
extern "C" BOOL APIENTRY DllMain(HINSTANCE hDllHandle, DWORD dwReason, LPVOID /*lpReserved*/)
{
switch (dwReason)
{
case DLL_PROCESS_ATTACH:
v_hModule = hDllHandle;
v_hPrivateHeap = HeapCreate(0, 0x1000, 0);
v_icoOffDocIcon = (HICON)LoadImage(hDllHandle, MAKEINTRESOURCE(IDI_SMALLOFFDOC), IMAGE_ICON, 16, 16, 0);
{
DWORD dwVersion = GetVersion();
v_fUnicodeAPI = ((dwVersion & 0x80000000) == 0);
v_fWindows2KPlus = ((v_fUnicodeAPI) && (LOBYTE(LOWORD(dwVersion)) > 4));
}
InitializeCriticalSection(&v_csecThreadSynch);
DisableThreadLibraryCalls(hDllHandle);
break;
case DLL_PROCESS_DETACH:
if (v_icoOffDocIcon) DeleteObject(v_icoOffDocIcon);
if (v_hPrivateHeap) HeapDestroy(v_hPrivateHeap);
DeleteCriticalSection(&v_csecThreadSynch);
break;
}
return TRUE;
}
开发者ID:QQiot,项目名称:DsoFramer,代码行数:29,代码来源:mainentry.cpp
注:本文中的HeapCreate函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论