这篇教程C++ AllocateMemory函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中AllocateMemory函数的典型用法代码示例。如果您正苦于以下问题:C++ AllocateMemory函数的具体用法?C++ AllocateMemory怎么用?C++ AllocateMemory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了AllocateMemory函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: CopyWideStringDWORD CopyWideString( IN _In_ LPWSTR pSrcWString, OUT _Out_ LPWSTR *pDestWString){ DWORD retCode = NO_ERROR; HRESULT hr = S_OK; size_t dwStringLength = 0; LPWSTR pTempString = NULL; *pDestWString = NULL; // Nothing to copy if(!pSrcWString) goto Cleanup; hr = StringCbLengthW(pSrcWString, (size_t)(STRSAFE_MAX_CCH * sizeof(wchar_t)), &dwStringLength); if (FAILED(hr)) { retCode = HRESULT_CODE(hr); goto Cleanup; } // StringCbLengthW - returns the length of string in bytes (excluding the null character). // StringCbCopyW expects the length of string in bytes (including the null character). dwStringLength += sizeof(wchar_t); retCode = AllocateMemory((DWORD)dwStringLength, (PVOID *)&pTempString); if(retCode != NO_ERROR) { goto Cleanup; } hr = StringCbCopyW((LPTSTR)pTempString, dwStringLength, pSrcWString); if (FAILED(hr)) { retCode = HRESULT_CODE(hr); goto Cleanup; } // // Set the OUT parameter // *pDestWString = pTempString;Cleanup: if((retCode != NO_ERROR) && (pTempString != NULL)) FreeMemory((PVOID *)&pTempString); pTempString = NULL; return retCode;}
开发者ID:9578577,项目名称:Windows-classic-samples,代码行数:49,
示例2: FAIL_RETURNUPK_STATUSNitroPlus::Open( PCWSTR FileName){ PVOID EntryBuffer; LARGE_INTEGER BytesRead; NTSTATUS Status; NITRO_PLUS_NPA_HEADER Header; Status = m_File.Open(FileName); FAIL_RETURN(Status); Status = m_File.Read(&Header, sizeof(Header), &BytesRead); FAIL_RETURN(Status); if ( BytesRead.LowPart != sizeof(Header) || (*(PULONG)Header.Signature & 0x00FFFFFF) != NPA_HEADER_MAGIC ) { return STATUS_UNSUCCESSFUL; } switch (Header.Version) { case NPA_GCLX_VERSION: break; default: return STATUS_UNSUCCESSFUL; } EntryBuffer = AllocateMemory(Header.EntrySize); if (EntryBuffer == NULL) return STATUS_INSUFFICIENT_RESOURCES; Status = m_File.Read(EntryBuffer, Header.EntrySize, &BytesRead); FAIL_RETURN(Status); if (BytesRead.LowPart != Header.EntrySize) return STATUS_UNSUCCESSFUL; Status = InitIndex(EntryBuffer, &Header); FreeMemory(EntryBuffer); return Status;}
开发者ID:Emiyasviel,项目名称:Arianrhod,代码行数:49,
示例3: LoadBofNameBool LoadBofName(char *fname){ FILE *f = fopen(fname, "rb"); if (f == NULL) { eprintf("LoadBofName can't open %s/n", fname); return False; } for (int i = 0; i < BOF_MAGIC_LEN; ++i) { unsigned char c; if (fread(&c, 1, 1, f) != 1 || c != magic_num[i]) { eprintf("LoadBofName %s is not in BOF format/n", fname); fclose(f); return False; } } int version; if (fread(&version, 1, 4, f) != 4 || version != 5) { eprintf("LoadBofName %s can't understand bof version != 5/n",fname); fclose(f); return False; } // Go back to start of file and read the whole thing into memory. fseek(f, 0, SEEK_SET); struct stat st; stat(fname, &st); int file_size = st.st_size; char *ptr = (char *)AllocateMemory(MALLOC_ID_LOADBOF,file_size); if (fread(ptr, 1, file_size, f) != file_size) { fclose(f); return False; } fclose(f); AddFileMem(fname,ptr,file_size); return True;}
开发者ID:Koveras,项目名称:Meridian59,代码行数:48,
示例4: CreateStringWithLenint CreateStringWithLen(char *buf,int len){ int string_id; string_node *snod; /* note: new_str is NOT null-terminated */ string_id = AllocateString(); snod = GetStringByID(string_id); snod->data = (char *)AllocateMemory(MALLOC_ID_STRING,len+1); memcpy(snod->data,buf,len); snod->len_data = len; snod->data[snod->len_data] = '/0'; return string_id;}
开发者ID:Koveras,项目名称:Meridian59,代码行数:16,
示例5: num_rows_TripletSparseMatrix::TripletSparseMatrix(int num_rows, int num_cols, int max_num_nonzeros) : num_rows_(num_rows), num_cols_(num_cols), max_num_nonzeros_(max_num_nonzeros), num_nonzeros_(0), rows_(NULL), cols_(NULL), values_(NULL) { // All the sizes should at least be zero CHECK_GE(num_rows, 0); CHECK_GE(num_cols, 0); CHECK_GE(max_num_nonzeros, 0); AllocateMemory();}
开发者ID:hanjianwei,项目名称:ACG-Tracker-Demo,代码行数:16,
示例6: InitAccountvoid InitAccount(void){ accounts = NULL; next_account_id = 1; console_account = &console_account_node; console_account->account_id = 0; console_account->name = ConfigStr(CONSOLE_ADMINISTRATOR); console_account->password = (char *)AllocateMemory(MALLOC_ID_ACCOUNT,1); console_account->password[0] = 0; console_account->type = ACCOUNT_ADMIN; console_account->last_login_time = 0; console_account->suspend_time = 0; console_account->credits = 0;}
开发者ID:AlleyCat1976,项目名称:Meridian59_103,代码行数:16,
示例7: AllocateObjectint AllocateObject(int class_id){ int old_objects; class_node *c; c = GetClassByID(class_id); if (c == NULL) { eprintf("AllocateObject can't find class id %i/n",class_id); return INVALID_OBJECT; } if (num_objects == max_objects) { old_objects = max_objects; max_objects = max_objects * 2; objects = (object_node *) ResizeMemory(MALLOC_ID_OBJECT,objects,old_objects*sizeof(object_node), max_objects*sizeof(object_node)); lprintf("AllocateObject resized to %i objects/n",max_objects); } objects[num_objects].object_id = num_objects; objects[num_objects].class_id = class_id; objects[num_objects].deleted = False; objects[num_objects].num_props = 1 + c->num_properties; objects[num_objects].p = (prop_type *)AllocateMemory(MALLOC_ID_OBJECT_PROPERTIES, sizeof(prop_type)*(1+c->num_properties)); if (ConfigBool(DEBUG_INITPROPERTIES)) { int i; prop_type p; p.id = 0; p.val.v.tag = TAG_INVALID; p.val.v.data = 0; for (i = 0; i < (1+c->num_properties); i++) { objects[num_objects].p[i] = p; } } return num_objects++;}
开发者ID:AlleyCat1976,项目名称:Meridian59_103,代码行数:46,
示例8: CreateAccountFromSMTPMailvoid CreateAccountFromSMTPMail(smtp_node *smtp){#ifdef SMTP_TEST return;#else int len_buf; char *buf; string_list *sl; /* put mail into buffer, than analyze, then free buffer */ len_buf = 0; sl = smtp->data; while (sl != NULL) { len_buf += strlen(sl->str); sl = sl->next; } buf = (char *) AllocateMemory(MALLOC_ID_SMTP,len_buf+1); len_buf = 0; sl = smtp->data; while (sl != NULL) { strcpy(buf+len_buf,sl->str); len_buf += strlen(sl->str); sl = sl->next; } if (strcmp(smtp->forward_path->str,ConfigStr(EMAIL_ACCOUNT_CREATE_NAME)) == 0) { CreateAccountFromBuffer(buf); } else { if (strcmp(smtp->forward_path->str,ConfigStr(EMAIL_ACCOUNT_DELETE_NAME)) == 0) DeleteAccountFromBuffer(buf); } FreeMemory(MALLOC_ID_SMTP,buf,len_buf+1);#endif}
开发者ID:Shaijan,项目名称:Meridian59,代码行数:44,
示例9: CreateQueueHeadPQUEUE_HEADCreateQueueHead(PEHCI_HOST_CONTROLLER hcd){ PQUEUE_HEAD CurrentQH; ULONG PhysicalAddress , i; KIRQL OldIrql; KeAcquireSpinLock(&hcd->Lock, &OldIrql); CurrentQH = (PQUEUE_HEAD)AllocateMemory(hcd, sizeof(QUEUE_HEAD), &PhysicalAddress); RtlZeroMemory(CurrentQH, sizeof(QUEUE_HEAD)); ASSERT(CurrentQH); CurrentQH->PhysicalAddr = PhysicalAddress; CurrentQH->HorizontalLinkPointer = TERMINATE_POINTER; CurrentQH->AlternateNextPointer = TERMINATE_POINTER; CurrentQH->NextPointer = TERMINATE_POINTER; /* 1 for non high speed, 0 for high speed device */ CurrentQH->EndPointCharacteristics.ControlEndPointFlag = 0; CurrentQH->EndPointCharacteristics.HeadOfReclamation = FALSE; CurrentQH->EndPointCharacteristics.MaximumPacketLength = 64; /* Set NakCountReload to max value possible */ CurrentQH->EndPointCharacteristics.NakCountReload = 0xF; /* Get the Initial Data Toggle from the QEDT */ CurrentQH->EndPointCharacteristics.QEDTDataToggleControl = FALSE; /* High Speed Device */ CurrentQH->EndPointCharacteristics.EndPointSpeed = QH_ENDPOINT_HIGHSPEED; CurrentQH->EndPointCapabilities.NumberOfTransactionPerFrame = 0x03; CurrentQH->Token.DWord = 0; CurrentQH->NextQueueHead = NULL; CurrentQH->PreviousQueueHead = NULL; for (i=0; i<5; i++) CurrentQH->BufferPointer[i] = 0; CurrentQH->Token.Bits.InterruptOnComplete = FALSE; KeReleaseSpinLock(&hcd->Lock, OldIrql); return CurrentQH;}
开发者ID:HBelusca,项目名称:NasuTek-Odyssey,代码行数:44,
示例10: initializeTestDatavoid initializeTestData(){ root = AllocateMemory(1); struct tree *left1 = AllocateMemory(2); struct tree *left11 = AllocateMemory(4); struct tree *left12 = AllocateMemory(5); struct tree *right1 = AllocateMemory(3); struct tree *right11 = AllocateMemory(6); struct tree *right12 = AllocateMemory(7); root->left = left1; root->right=right1; left1->left=left11; left1->right=left12; right1->left=right11; right1->right=right12; }
开发者ID:batraman,项目名称:sandbox,代码行数:17,
示例11: input_stream void Kernel::CreateProcess(const std::string &name) { if (_last_issued_process_id == std::numeric_limits<Process::process_id_type>::max()) { std::cerr << "Kernel: failed to create a new process. The maximum number of processes has been reached." << std::endl; } else { std::ifstream input_stream(name, std::ios::in | std::ios::binary); if (!input_stream) { std::cerr << "Kernel: failed to open the program file." << std::endl; } else { MMU::ram_type ops; input_stream.seekg(0, std::ios::end); auto file_size = input_stream.tellg(); input_stream.seekg(0, std::ios::beg); ops.resize(static_cast<MMU::ram_size_type>(file_size) / 4); input_stream.read(reinterpret_cast<char *>(&ops[0]), file_size); if (input_stream.bad()) { std::cerr << "Kernel: failed to read the program file." << std::endl; } else { MMU::ram_size_type new_memory_position = AllocateMemory(ops.size()); // TODO: allocate memory for the process (AllocateMemory) if (new_memory_position == -1) { std::cerr << "Kernel: failed to allocate memory." << std::endl; } else { std::copy(ops.begin(), ops.end(), (machine.mmu.ram.begin() + new_memory_position)); Process process(_last_issued_process_id++, new_memory_position, new_memory_position + ops.size()); // Old sequential allocation // // std::copy(ops.begin(), ops.end(), (machine.memory.ram.begin() + _last_ram_position)); // // Process process(_last_issued_process_id++, _last_ram_position, // _last_ram_position + ops.size()); // // _last_ram_position += ops.size(); } } } } }
开发者ID:vidanissa,项目名称:os_Project_Full,代码行数:43,
示例12: AllocateMemory//*****************************************************************************// Called to read the data into allocated memory and release the backing store.// Only available on read-only data.//*****************************************************************************HRESULT StgIO::LoadFileToMemory(){ HRESULT hr; void *pData; // Allocated buffer for file. ULONG cbData; // Size of the data. ULONG cbRead = 0; // Data actually read. // Make sure it is a read-only file. if (m_fFlags & DBPROP_TMODEF_WRITE) return E_INVALIDARG; // Try to allocate the buffer. cbData = m_cbData; pData = AllocateMemory(cbData); IfNullGo(pData); // Try to read the file into the buffer. IfFailGo(Read(pData, cbData, &cbRead)); if (cbData != cbRead) { _ASSERTE_MSG(FALSE, "Read didn't succeed."); IfFailGo(CLDB_E_FILE_CORRUPT); } // Done with the old data. Close(); // Open with new data. hr = Open(NULL /* szName */, STGIO_READ, pData, cbData, NULL /* IStream* */, NULL /* lpSecurityAttributes */); _ASSERTE(SUCCEEDED(hr)); // should not be a failure code path with open on buffer. // Mark the new memory so that it will be freed later. m_pBaseData = m_pData; m_bFreeMem = true; ErrExit: if (FAILED(hr) && pData) FreeMemory(pData); return hr;} // StgIO::LoadFileToMemory
开发者ID:A-And,项目名称:coreclr,代码行数:46,
示例13: INHERITEDGrVkSubHeap::GrVkSubHeap(const GrVkGpu* gpu, uint32_t memoryTypeIndex, VkDeviceSize size, VkDeviceSize alignment) : INHERITED(size, alignment) , fGpu(gpu) , fMemoryTypeIndex(memoryTypeIndex) { VkMemoryAllocateInfo allocInfo = { VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, // sType NULL, // pNext size, // allocationSize memoryTypeIndex, // memoryTypeIndex }; VkResult err = GR_VK_CALL(gpu->vkInterface(), AllocateMemory(gpu->device(), &allocInfo, nullptr, &fAlloc)); if (VK_SUCCESS != err) { this->reset(); }}
开发者ID:rlugojr,项目名称:skia,代码行数:21,
示例14: AddFileMem/* add a filename and mapped ptr to the list of loaded files */void AddFileMem(char *fname,char *ptr,int size){ loaded_bof_node *lf; /* make new loaded_file node */ lf = (loaded_bof_node *)AllocateMemory(MALLOC_ID_LOADBOF,sizeof(loaded_bof_node)); strcpy(lf->fname,fname); lf->mem = ptr; lf->length = size; /* we store the fname so the class structures can point to it, but kill the path */ if (strrchr(lf->fname,'//') == NULL) FindClasses(lf->mem,lf->fname); else FindClasses(lf->mem,strrchr(lf->fname,'//')+1); /* add to front of list */ lf->next = mem_files; mem_files = lf;}
开发者ID:Koveras,项目名称:Meridian59,代码行数:22,
示例15: AssociateUserBool AssociateUser(int account_id,int object_id){ user_node *u; u = users; while (u != NULL) { if (u->object_id == object_id) return False; u = u->next; } u = (user_node *)AllocateMemory(MALLOC_ID_USER,sizeof(user_node)); u->account_id = account_id; u->object_id = object_id; u->next = users; users = u; return True;}
开发者ID:AlleyCat1976,项目名称:Meridian59_103,代码行数:21,
示例16: ForkStoreManagerpid_t ForkStoreManager() { pid_t sm_pid; int quit = 0; switch ((sm_pid = fork())) { case 0: logFilePointer = OpenLogFile(); //allocate shared memory AllocateMemory(); LoadTable(); while (quit == 0) { if (pipe1Done == 0) GetThreadedMessages(1, pipe1, pipe3); if (pipe2Done == 0) GetThreadedMessages(2, pipe2, pipe4); if (pipe1Done != 0 && pipe2Done != 0) { printf("quitting app/n"); quit = 1; } usleep(100); } exit(1); break; } return sm_pid;}
开发者ID:ttrask,项目名称:eggen-os,代码行数:40,
示例17: MakeStringFromSMTPMailint MakeStringFromSMTPMail(smtp_node *smtp){#ifdef SMTP_TEST return 0;#else int len_buf,string_id; char *buf; string_list *sl; /* cheesy here--allocate buffer, make the string, then free buffer. would be nice to not have to allocate here */ len_buf = 0; sl = smtp->data; while (sl != NULL) { len_buf += strlen(sl->str); sl = sl->next; } buf = (char *) AllocateMemory(MALLOC_ID_SMTP,len_buf+1); len_buf = 0; sl = smtp->data; while (sl != NULL) { strcpy(buf+len_buf,sl->str); len_buf += strlen(sl->str); sl = sl->next; } string_id = CreateStringWithLen(buf,len_buf+1); FreeMemory(MALLOC_ID_SMTP,buf,len_buf); return string_id; #endif}
开发者ID:Shaijan,项目名称:Meridian59,代码行数:40,
示例18: LowQueryPathFromComponentARC_STATUSLowQueryPathFromComponent( IN PCONFIGURATION_COMPONENT Component, OUT PCHAR* Path )/*++Routine Description: This routine computes a path from a component. The resulting path is allocated on the heap.Arguments: Component - Supplies a component. Path - Returns the path corresponding to that component.Return Value: ENOMEM, ESUCCESS--*/{ PCHAR p; PCHAR path; p = AlGetPathnameFromComponent(Component); path = AllocateMemory(strlen(p) + 1); if (!path) { return ENOMEM; } strcpy(path, p); *Path = path; return ESUCCESS;}
开发者ID:BuloZB,项目名称:WinNT4,代码行数:40,
示例19: CreateTimerint CreateTimer(int object_id,int message_id,int milliseconds){ timer_node *t; if (deleted_timers == NULL) t = (timer_node *)AllocateMemory(MALLOC_ID_TIMER,sizeof(timer_node)); else { /* dprintf("recovering former timer id %i/n",deleted_timers->timer_id); */ t = deleted_timers; deleted_timers = deleted_timers->next; } t->timer_id = next_timer_num++; t->object_id = object_id; t->message_id = message_id; t->time = GetMilliCount() + milliseconds; AddTimerNode(t); numActiveTimers++; return t->timer_id;}
开发者ID:GarOfMeridian,项目名称:Meridian59_103,代码行数:23,
示例20: AllocateMemory/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% %% %% S e t M a g i c k I n f o %% %% %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Method SetMagickInfo allocates a MagickInfo structure and initializes the% members to default values.%% The format of the SetMagickInfo method is:%% MagickInfo *SetMagickInfo(const char *tag)%% A description of each parameter follows:%% o magick_info: Method SetMagickInfo returns the allocated and initialized% MagickInfo structure.%% o tag: a character string that represents the image format associated% with the MagickInfo structure.%%*/Export MagickInfo *SetMagickInfo(const char *tag){ MagickInfo *entry; entry=(MagickInfo *) AllocateMemory(sizeof(MagickInfo)); if (entry == (MagickInfo *) NULL) MagickError(ResourceLimitError,"Unable to allocate image", "Memory allocation failed"); entry->tag=AllocateString(tag); entry->decoder=(Image *(*)(const ImageInfo *)) NULL; entry->encoder=(unsigned int (*)(const ImageInfo *,Image *)) NULL; entry->magick= (unsigned int (*)(const unsigned char *,const unsigned int)) NULL; entry->adjoin=True; entry->blob_support=True; entry->raw=False; entry->description=(char *) NULL; entry->data=(void *) NULL; entry->previous=(MagickInfo *) NULL; entry->next=(MagickInfo *) NULL; return(entry);}
开发者ID:SOLARIC,项目名称:world-opponent-network,代码行数:51,
示例21: ASSERTvoid CDib::CreatFromHandle(HDIB hDib){ ASSERT (hDib!=NULL); DWORD dwSizeDib=GlobalSize(hDib); void* lpDib = ::GlobalLock(hDib); m_dwLength=dwSizeDib+sizeof(BITMAPFILEHEADER); DWORD dwLenHead=sizeof(BITMAPFILEHEADER); DWORD dwLen = m_dwLength-dwLenHead; if(!AllocateMemory()) return; memcpy((LPBYTE)m_lpBMIH,lpDib,dwLen); int nPaletteSize=PaletteSize(m_lpBMI); m_lpBMFH->bfType=0x4d42;//"BM" m_lpBMFH->bfSize=m_dwLength; m_lpBMFH->bfReserved1=0; m_lpBMFH->bfReserved2=0; m_lpBMFH->bfOffBits=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+ nPaletteSize; ::GlobalUnlock(hDib);}
开发者ID:fightx,项目名称:Script.NET,代码行数:23,
示例22: LoadTimerBool LoadTimer(int timer_id,int object_id,char *message_name,int milliseconds){ object_node *o; timer_node *t; message_node *m; o = GetObjectByID(object_id); if (o == NULL) { eprintf("LoadTimer can't find object %i/n",object_id); return False; } m = GetMessageByName(o->class_id,message_name,NULL); if (m == NULL) { eprintf("LoadTimer can't find message name %s/n",message_name); return False; } t = (timer_node *)AllocateMemory(MALLOC_ID_TIMER,sizeof(timer_node)); t->timer_id = timer_id; t->object_id = object_id; t->message_id = m->message_id; t->time = GetMilliCount() + milliseconds; AddTimerNode(t); numActiveTimers++; /* the timers weren't saved in numerical order, but they were * compacted to first x non-negative integers */ if (timer_id >= next_timer_num) next_timer_num = timer_id + 1; return True;}
开发者ID:GarOfMeridian,项目名称:Meridian59_103,代码行数:37,
示例23: MapDocumentbool MemoryContext::MapDocument(Document const& rDoc, CpuContext const* pCpuCtxt){ bool Res = true; rDoc.ForEachMemoryArea([&](MemoryArea const& rMemArea) { Address const& rMemAreaAddr = rMemArea.GetBaseAddress(); u32 MemAreaSize = rMemArea.GetSize(); u32 MemAreaFileSize = rMemArea.GetFileSize(); void* pRawMemory; u64 LinearAddress; if (pCpuCtxt->Translate(rMemAreaAddr, LinearAddress) == false) LinearAddress = rMemAreaAddr.GetOffset(); if (AllocateMemory(LinearAddress, MemAreaSize, &pRawMemory) == false) { Res = false; return; } // TODO: Do we have to zero-out memory? if (MemAreaFileSize == 0x0) return; TOffset MemAreaFileOff; if (rMemArea.ConvertOffsetToFileOffset(rMemAreaAddr.GetOffset(), MemAreaFileOff) == false) return; if (!rDoc.GetBinaryStream().Read(MemAreaFileOff, pRawMemory, MemAreaFileSize)) { FreeMemory(LinearAddress); Res = false; return; } }); return Res;}
开发者ID:anat,项目名称:medusa,代码行数:37,
示例24: AddBlockvoid AddBlock(int iSeconds, struct in_addr* piaPeer){ block_node* pBlock = FindBlock(piaPeer); int iExpires = (iSeconds < 0)? -1 : GetTime() + iSeconds; // A block set to expire at -1 will stay in effect until all blocks are deleted. // (Usually when server is shut down and later restarted.) if (pBlock) { if (pBlock->iExpires >= 0) pBlock->iExpires = iExpires; return; } pBlock = (block_node *) AllocateMemory(MALLOC_ID_BLOCK,sizeof(block_node)); if (pBlock) { pBlock->iExpires = iExpires; pBlock->iaPeer = *piaPeer; pBlock->next = block_head; block_head = pBlock; }}
开发者ID:AlleyCat1976,项目名称:Meridian59_103,代码行数:24,
示例25: main//.........这里部分代码省略......... printf("Input data has the dimensions %zu x %zu x %zu, while the mask volume has the dimensions %zu x %zu x %zu. Aborting! /n",DATA_W,DATA_H,DATA_D,TEMP_DATA_W,TEMP_DATA_H,TEMP_DATA_D); FreeAllNiftiImages(allNiftiImages,numberOfNiftiImages); return EXIT_FAILURE; } } // Get voxel sizes EPI_VOXEL_SIZE_X = inputData->dx; EPI_VOXEL_SIZE_Y = inputData->dy; EPI_VOXEL_SIZE_Z = inputData->dz; // Calculate size, in bytes size_t DATA_SIZE = DATA_W * DATA_H * DATA_D * DATA_T * sizeof(float); size_t VOLUME_SIZE = DATA_W * DATA_H * DATA_D * sizeof(float); // Print some info if (PRINT) { printf("Authored by K.A. Eklund /n"); printf("Data size: %zu x %zu x %zu x %zu /n", DATA_W, DATA_H, DATA_D, DATA_T); printf("Voxel size: %f x %f x %f mm /n", EPI_VOXEL_SIZE_X, EPI_VOXEL_SIZE_Y, EPI_VOXEL_SIZE_Z); printf("Smoothing filter size: %f mm /n", EPI_SMOOTHING_AMOUNT); } // ------------------------------------------------ // Allocate memory on the host startTime = GetWallTime(); // If the data is in float format, we can just copy the pointer if ( inputData->datatype != DT_FLOAT ) { AllocateMemory(h_fMRI_Volumes, DATA_SIZE, allMemoryPointers, numberOfMemoryPointers, allNiftiImages, numberOfNiftiImages, allocatedHostMemory, "INPUT_DATA"); } else { allocatedHostMemory += DATA_SIZE; } AllocateMemory(h_Certainty, VOLUME_SIZE, allMemoryPointers, numberOfMemoryPointers, allNiftiImages, numberOfNiftiImages, allocatedHostMemory, "CERTAINTY"); endTime = GetWallTime(); if (VERBOS) { printf("It took %f seconds to allocate memory/n",(float)(endTime - startTime)); } startTime = GetWallTime(); // Convert data to floats if ( inputData->datatype == DT_SIGNED_SHORT ) { short int *p = (short int*)inputData->data; for (size_t i = 0; i < DATA_W * DATA_H * DATA_D * DATA_T; i++) { h_fMRI_Volumes[i] = (float)p[i]; } } else if ( inputData->datatype == DT_UINT8 ) { unsigned char *p = (unsigned char*)inputData->data; for (size_t i = 0; i < DATA_W * DATA_H * DATA_D * DATA_T; i++) {
开发者ID:pmolfese,项目名称:BROCCOLI,代码行数:67,
示例26: SetAccountPasswordAlreadyEncryptedvoid SetAccountPasswordAlreadyEncrypted(account_node *a,char *password){ FreeMemory(MALLOC_ID_ACCOUNT,a->password,strlen(a->password)+1); a->password = (char *)AllocateMemory(MALLOC_ID_ACCOUNT,strlen(password)+1); strcpy(a->password,password);}
开发者ID:AlleyCat1976,项目名称:Meridian59_103,代码行数:6,
示例27: SetAccountNamevoid SetAccountName(account_node *a,char *name){ FreeMemory(MALLOC_ID_ACCOUNT,a->name,strlen(a->name)+1); a->name = (char *)AllocateMemory(MALLOC_ID_ACCOUNT,strlen(name)+1); strcpy(a->name,name);}
开发者ID:AlleyCat1976,项目名称:Meridian59_103,代码行数:6,
示例28: main int main(int argc, char **argv) { struct sockaddr_in addr; int sock_fd, addrlen; /* 获得程序工作的参数,如 IP 、端口、监听数、网页根目录、目录存放位置等 */ getoption(argc, argv); if (!host) { addrlen = strlen(DEFAULTIP); AllocateMemory(&host, addrlen, DEFAULTIP); } if (!port) { addrlen = strlen(DEFAULTPORT); AllocateMemory(&port, addrlen, DEFAULTPORT); } if (!back) { addrlen = strlen(DEFAULTBACK); AllocateMemory(&back, addrlen, DEFAULTBACK); } if (!dirroot) { addrlen = strlen(DEFAULTDIR); AllocateMemory(&dirroot, addrlen, DEFAULTDIR); } if (!logdir) { addrlen = strlen(DEFAULTLOG); AllocateMemory(&logdir, addrlen, DEFAULTLOG); } printf ("host=%s port=%s back=%s dirroot=%s logdir=%s %s是后台工作模式(进程ID:%d)/n", host, port, back, dirroot, logdir, daemon_y_n?"":"不", getpid()); /* fork() 两次处于后台工作模式下 */ if (daemon_y_n) { if (fork()) exit(0); if (fork()) exit(0); close(0), close(1), close(2); logfp = fopen(logdir, "a+"); if (!logfp) exit(0); } /* 处理子进程退出以免产生僵尸进程 */ signal(SIGCHLD, SIG_IGN); /* 创建 socket */ if ((sock_fd = socket(PF_INET, SOCK_STREAM, 0)) < 0) { if (!daemon_y_n) { prterrmsg("socket()"); } else { wrterrmsg("socket()"); } } /* 设置端口快速重用 */ addrlen = 1; setsockopt(sock_fd, SOL_SOCKET, SO_REUSEADDR, &addrlen, sizeof(addrlen)); addr.sin_family = AF_INET; addr.sin_port = htons(atoi(port)); addr.sin_addr.s_addr = inet_addr(host); addrlen = sizeof(struct sockaddr_in); /* 绑定地址、端口等信息 */ if (bind(sock_fd, (struct sockaddr *) &addr, addrlen) < 0) { if (!daemon_y_n) { prterrmsg("bind()"); } else { wrterrmsg("bind()"); } } /* 开启临听 */ if (listen(sock_fd, atoi(back)) < 0) { if (!daemon_y_n) { prterrmsg("listen()"); } else { wrterrmsg("listen()"); } } while (1) { int len; int new_fd; addrlen = sizeof(struct sockaddr_in); /* 接受新连接请求 */ new_fd = accept(sock_fd, (struct sockaddr *) &addr, &addrlen); if (new_fd < 0) { if (!daemon_y_n) { prterrmsg("accept()"); } else { wrterrmsg("accept()"); } break; } bzero(buffer, MAXBUF + 1); sprintf(buffer, "连接来自于: %s:%d/n", inet_ntoa(addr.sin_addr), ntohs(addr.sin_port));//.........这里部分代码省略.........
开发者ID:ch5637,项目名称:zengqiu,代码行数:101,
示例29: QMainWindowMainWindow::MainWindow( QWidget * parent) : QMainWindow(parent){ setupUi(this); version = "2015-08-28"; inimage = false; x1drag = false; x2drag = false; y1drag = false; y2drag = false; image = QImage(); pixmap = scene.addPixmap(QPixmap()); pixmap->setZValue(0); QPen pen; pen.setColor(QColor(255,255,0)); pen.setStyle(Qt::DashLine); // limit lines x1line = scene.addLine(QLineF(), pen); x1line->setZValue(1); x2line = scene.addLine(QLineF(), pen); x2line->setZValue(1); y1line = scene.addLine(QLineF(), pen); y1line->setZValue(1); y2line = scene.addLine(QLineF(), pen); y2line->setZValue(1); pen.setColor(QColor(255,0,0)); pen.setStyle(Qt::SolidLine); // projections, beam profile, centroid xprojection = scene.addPath(QPainterPath(), pen); xprojection->setZValue(2); yprojection = scene.addPath(QPainterPath(), pen); yprojection->setZValue(2); ellipse = scene.addEllipse(0,0,0,0, pen); ellipse->setZValue(2); centerAline = scene.addLine(QLineF(), pen); centerAline->setZValue(2); centerBline = scene.addLine(QLineF(), pen); centerBline->setZValue(2); QObject::connect(&scene, SIGNAL(mouseMoved()), this, SLOT(mouseMovedOnScene())); QObject::connect(&scene, SIGNAL(mousePressed()), this, SLOT(mousePressedOnScene())); QObject::connect(&scene, SIGNAL(mouseReleased()), this, SLOT(mouseReleasedOnScene())); QObject::connect(&scene, SIGNAL(mouseLeft()), this, SLOT(mouseLeftScene())); graphicsView->setScene(&scene); graphicsView->setContextMenuPolicy(Qt::CustomContextMenu); X1SpinBox->setRange(0, MAX_HEIGHT-1); X2SpinBox->setRange(0, MAX_HEIGHT-1); Y1SpinBox->setRange(0, MAX_WIDTH-1); Y2SpinBox->setRange(0, MAX_WIDTH-1); scaleLabel->setScaledContents(true); AllocateMemory(); dataloaded = false; refloaded = false; RestoreSession(); LoadRef(reffile); LoadData(datafile); // Scale image scale = QImage(20, 256, QImage::Format_Indexed8); SetColorTable(); for(int i=0; i<20; i++) for(int j=0; j<=255; j++) scale.setPixel(i, j, 255-j); scaleLabel->setPixmap(QPixmap::fromImage(scale)); graphicsView->scale(pow(2,zoom/2), pow(2,zoom/2)); InitializeShortcuts(); UpdateVisibility();}
开发者ID:polyanskiy,项目名称:easyFG,代码行数:81,
示例30: mainint main(int argc, char **argv){ struct sockaddr_in addr; int sock_fd, addrlen; getoption(argc, argv); if (!host) { addrlen = strlen(DEFAULTIP); AllocateMemory(&host, addrlen, DEFAULTIP); } if (!port) { addrlen = strlen(DEFAULTPORT); AllocateMemory(&port, addrlen, DEFAULTPORT); } if (!back) { addrlen = strlen(DEFAULTBACK); AllocateMemory(&back, addrlen, DEFAULTBACK); } if (!dirroot) { addrlen = strlen(DEFAULTDIR); AllocateMemory(&dirroot, addrlen, DEFAULTDIR); } if (!logdir) { addrlen = strlen(DEFAULTLOG); AllocateMemory(&logdir, addrlen, DEFAULTLOG); } printf ("host=%s port=%s back=%s dirroot=%s logdir=%s %s daemon mode (pID:%d)/n", host, port, back, dirroot, logdir, daemon_y_n?"":"is not", getpid()); /* fork() twice for daemon */ if (daemon_y_n) { if (fork()) exit(0); if (fork()) exit(0); close(0), close(1), close(2); logfp = fopen(logdir, "a+"); if (!logfp) exit(0); } signal(SIGCHLD, SIG_IGN); if ((sock_fd = socket(PF_INET, SOCK_STREAM, 0)) < 0) { if (!daemon_y_n) { prterrmsg("socket()"); } else { wrterrmsg("socket()"); } } addrlen = 1; setsockopt(sock_fd, SOL_SOCKET, SO_REUSEADDR, &addrlen, sizeof(addrlen)); addr.sin_family = AF_INET; addr.sin_port = htons(atoi(port)); addr.sin_addr.s_addr = inet_addr(host); addrlen = sizeof(struct sockaddr_in); if (bind(sock_fd, (struct sockaddr *) &addr, addrlen) < 0) { if (!daemon_y_n) { prterrmsg("bind()"); } else { wrterrmsg("bind()"); } } if (listen(sock_fd, atoi(back)) < 0) { if (!daemon_y_n) { prterrmsg("listen()"); } else { wrterrmsg("listen()"); } } while (1) { int len; int new_fd; addrlen = sizeof(struct sockaddr_in); new_fd = accept(sock_fd, (struct sockaddr *) &addr, &addrlen); if (new_fd < 0) { if (!daemon_y_n) { prterrmsg("accept()"); } else { wrterrmsg("accept()"); } break; } bzero(buffer, MAXBUF + 1); sprintf(buffer, "connection from : %s:%d/n", inet_ntoa(addr.sin_addr), ntohs(addr.sin_port)); if (!daemon_y_n) { prtinfomsg(buffer); } else { wrtinfomsg(buffer); }//.........这里部分代码省略.........
开发者ID:tetang1230,项目名称:linux_c,代码行数:101,
注:本文中的AllocateMemory函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ AllocatePages函数代码示例 C++ AllocateHeap函数代码示例 |