这篇教程C++ ALIGN_SIZE函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中ALIGN_SIZE函数的典型用法代码示例。如果您正苦于以下问题:C++ ALIGN_SIZE函数的具体用法?C++ ALIGN_SIZE怎么用?C++ ALIGN_SIZE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了ALIGN_SIZE函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: my_multi_mallocvoid* my_multi_malloc(myf myFlags, ...){ va_list args; char **ptr,*start,*res; size_t tot_length,length; DBUG_ENTER("my_multi_malloc"); va_start(args,myFlags); tot_length=0; while ((ptr=va_arg(args, char **))) { length=va_arg(args,uint); tot_length+=ALIGN_SIZE(length); } va_end(args); if (!(start=(char *) my_malloc(tot_length,myFlags))) DBUG_RETURN(0); /* purecov: inspected */ va_start(args,myFlags); res=start; while ((ptr=va_arg(args, char **))) { *ptr=res; length=va_arg(args,uint); res+=ALIGN_SIZE(length); } va_end(args); DBUG_RETURN((void*) start);}
开发者ID:0x00xw,项目名称:mysql-2,代码行数:30,
示例2: request/*================idHeap::Msize returns size of allocated memory block p = pointer to memory block Notes: size may not be the same as the size in the original allocation request (due to block alignment reasons).================*/dword idHeap::Msize( void *p ) { if ( !p ) { return 0; }#if USE_LIBC_MALLOC #ifdef _WIN32 return _msize( p ); #else return 0; #endif#else switch( ((byte *)(p))[-1] ) { case SMALL_ALLOC: { return SMALL_ALIGN( ((byte *)(p))[-SMALL_HEADER_SIZE] * ALIGN ); } case MEDIUM_ALLOC: { return ((mediumHeapEntry_s *)(((byte *)(p)) - ALIGN_SIZE( MEDIUM_HEADER_SIZE )))->size - ALIGN_SIZE( MEDIUM_HEADER_SIZE ); } case LARGE_ALLOC: { return ((idHeap::page_s*)(*((dword *)(((byte *)p) - ALIGN_SIZE( LARGE_HEADER_SIZE )))))->dataSize - ALIGN_SIZE( LARGE_HEADER_SIZE ); } default: { idLib::common->FatalError( "idHeap::Msize: invalid memory block (%s)", idLib::sys->GetCallStackCurStr( 4 ) ); return 0; } }#endif}
开发者ID:sbrown345,项目名称:doom3_emscripten,代码行数:40,
示例3: init_alloc_rootvoid init_alloc_root(MEM_ROOT *mem_root, size_t block_size, size_t pre_alloc_size __attribute__((unused))){ DBUG_ENTER("init_alloc_root"); DBUG_PRINT("enter",("root: 0x%lx", (long) mem_root)); mem_root->free= mem_root->used= mem_root->pre_alloc= 0; mem_root->min_malloc= 32; mem_root->block_size= block_size - ALLOC_ROOT_MIN_BLOCK_SIZE; mem_root->error_handler= 0; mem_root->block_num= 4; /* We shift this with >>2 */ mem_root->first_block_usage= 0;#if !(defined(HAVE_purify) && defined(EXTRA_DEBUG)) if (pre_alloc_size) { if ((mem_root->free= mem_root->pre_alloc= (USED_MEM*) my_malloc(pre_alloc_size+ ALIGN_SIZE(sizeof(USED_MEM)), MYF(0)))) { mem_root->free->size= pre_alloc_size+ALIGN_SIZE(sizeof(USED_MEM)); mem_root->free->left= pre_alloc_size; mem_root->free->next= 0; } }#endif DBUG_VOID_RETURN;}
开发者ID:16898500,项目名称:SkyFireEMU,代码行数:28,
示例4: init_alloc_rootvoid init_alloc_root(PSI_memory_key key, MEM_ROOT *mem_root, size_t block_size, size_t pre_alloc_size __attribute__((unused))){ DBUG_ENTER("init_alloc_root"); DBUG_PRINT("enter",("root: 0x%lx", (long) mem_root)); mem_root->free= mem_root->used= mem_root->pre_alloc= 0; mem_root->min_malloc= 32; mem_root->block_size= block_size - ALLOC_ROOT_MIN_BLOCK_SIZE; mem_root->error_handler= 0; mem_root->block_num= 4; /* We shift this with >>2 */ mem_root->first_block_usage= 0; mem_root->m_psi_key= key; mem_root->max_capacity= 0; mem_root->allocated_size= 0; mem_root->error_for_capacity_exceeded= FALSE;#if defined(PREALLOCATE_MEMORY_CHUNKS) if (pre_alloc_size) { if ((mem_root->free= mem_root->pre_alloc= (USED_MEM*) my_malloc(key, pre_alloc_size+ ALIGN_SIZE(sizeof(USED_MEM)), MYF(0)))) { mem_root->free->size= (uint)(pre_alloc_size+ALIGN_SIZE(sizeof(USED_MEM))); mem_root->free->left= (uint)pre_alloc_size; mem_root->free->next= 0; mem_root->allocated_size+= pre_alloc_size+ ALIGN_SIZE(sizeof(USED_MEM)); } }#endif DBUG_VOID_RETURN;}
开发者ID:Longhui,项目名称:mysql-5.7.9-readcode,代码行数:35,
示例5: UnpackDevicePathEFI_DEVICE_PATH *UnpackDevicePath ( IN EFI_DEVICE_PATH *DevPath ){ EFI_DEVICE_PATH *Src, *Dest, *NewPath; UINTN Size; // // Walk device path and round sizes to valid boundries // Src = DevPath; Size = 0; for (; ;) { Size += DevicePathNodeLength(Src); Size += ALIGN_SIZE(Size); if (IsDevicePathEnd(Src)) { break; } Src = NextDevicePathNode(Src); } // // Allocate space for the unpacked path // NewPath = AllocateZeroPool (Size); if (NewPath) { ASSERT (((UINTN)NewPath) % MIN_ALIGNMENT_SIZE == 0); // // Copy each node // Src = DevPath; Dest = NewPath; for (; ;) { Size = DevicePathNodeLength(Src); CopyMem (Dest, Src, Size); Size += ALIGN_SIZE(Size); SetDevicePathNodeLength (Dest, Size); Dest->Type |= EFI_DP_TYPE_UNPACKED; Dest = (EFI_DEVICE_PATH *) (((UINT8 *) Dest) + Size); if (IsDevicePathEnd(Src)) { break; } Src = NextDevicePathNode(Src); } } return NewPath;}
开发者ID:SvenDowideit,项目名称:clearlinux,代码行数:59,
示例6: alloc_rootgptr alloc_root(MEM_ROOT *mem_root, size_t Size){#if defined(HAVE_purify) && defined(EXTRA_DEBUG) reg1 USED_MEM *next; Size+=ALIGN_SIZE(sizeof(USED_MEM)); if (!(next = (USED_MEM*) my_malloc(Size,MYF(MY_WME)))) { if (mem_root->error_handler) (*mem_root->error_handler)(); return((gptr) 0); /* purecov: inspected */ } next->next=mem_root->used; mem_root->used=next; return (gptr) (((char*) next)+ALIGN_SIZE(sizeof(USED_MEM)));#else size_t get_size,max_left; gptr point; reg1 USED_MEM *next; reg2 USED_MEM **prev; Size= ALIGN_SIZE(Size); prev= &mem_root->free; max_left=0; for (next= *prev ; next && next->left < Size ; next= next->next) { if (next->left > max_left) max_left=next->left; prev= &next->next; } if (! next) { /* Time to alloc new block */ get_size= Size+ALIGN_SIZE(sizeof(USED_MEM)); if (max_left*4 < mem_root->block_size && get_size < mem_root->block_size) get_size=mem_root->block_size; /* Normal alloc */ if (!(next = (USED_MEM*) my_malloc(get_size,MYF(MY_WME)))) { if (mem_root->error_handler) (*mem_root->error_handler)(); return((gptr) 0); /* purecov: inspected */ } next->next= *prev; next->size= get_size; next->left= get_size-ALIGN_SIZE(sizeof(USED_MEM)); *prev=next; } point= (gptr) ((char*) next+ (next->size-next->left)); if ((next->left-= Size) < mem_root->min_malloc) { /* Full block */ *prev=next->next; /* Remove block from list */ next->next=mem_root->used; mem_root->used=next; } return(point);#endif}
开发者ID:dparnell,项目名称:MariaDB,代码行数:57,
示例7: reset_root_defaultsvoid reset_root_defaults(MEM_ROOT *mem_root, size_t block_size, size_t pre_alloc_size __attribute__((unused))){ DBUG_ASSERT(alloc_root_inited(mem_root)); mem_root->block_size= (((block_size - ALLOC_ROOT_MIN_BLOCK_SIZE) & ~1) | (mem_root->block_size & 1));#if !(defined(HAVE_valgrind) && defined(EXTRA_DEBUG)) if (pre_alloc_size) { size_t size= pre_alloc_size + ALIGN_SIZE(sizeof(USED_MEM)); if (!mem_root->pre_alloc || mem_root->pre_alloc->size != size) { USED_MEM *mem, **prev= &mem_root->free; /* Free unused blocks, so that consequent calls to reset_root_defaults won't eat away memory. */ while (*prev) { mem= *prev; if (mem->size == size) { /* We found a suitable block, no need to do anything else */ mem_root->pre_alloc= mem; return; } if (mem->left + ALIGN_SIZE(sizeof(USED_MEM)) == mem->size) { /* remove block from the list and free it */ *prev= mem->next; my_free(mem); } else prev= &mem->next; } /* Allocate new prealloc block and add it to the end of free list */ if ((mem= (USED_MEM *) my_malloc(size, MYF(MALLOC_FLAG(mem_root-> block_size))))) { mem->size= size; mem->left= pre_alloc_size; mem->next= *prev; *prev= mem_root->pre_alloc= mem; } else { mem_root->pre_alloc= 0; } } } else#endif mem_root->pre_alloc= 0;}
开发者ID:knielsen,项目名称:mariadb,代码行数:56,
示例8: alloc_rootgptr alloc_root(MEM_ROOT *mem_root,unsigned int Size){#if defined(HAVE_purify) && defined(EXTRA_DEBUG) reg1 USED_MEM *next; Size+=ALIGN_SIZE(sizeof(USED_MEM)); if (!(next = (USED_MEM*) my_malloc(Size,MYF(MY_WME)))) { if (mem_root->error_handler) (*mem_root->error_handler)(); return((gptr) 0); /* purecov: inspected */ } next->next= mem_root->used; next->size= Size; mem_root->used= next; return (gptr) (((char*) next)+ALIGN_SIZE(sizeof(USED_MEM)));#else uint get_size, block_size; gptr point; reg1 USED_MEM *next= 0; reg2 USED_MEM **prev; Size= ALIGN_SIZE(Size); if ((*(prev= &mem_root->free)) != NULL) { if ((*prev)->left < Size && mem_root->first_block_usage++ >= ALLOC_MAX_BLOCK_USAGE_BEFORE_DROP && (*prev)->left < ALLOC_MAX_BLOCK_TO_DROP) { next= *prev; *prev= next->next; /* Remove block from list */ next->next= mem_root->used; mem_root->used= next; mem_root->first_block_usage= 0; } for (next= *prev ; next && next->left < Size ; next= next->next) prev= &next->next; } if (! next) { /* Time to alloc new block */ block_size= mem_root->block_size * (mem_root->block_num >> 2); get_size= Size+ALIGN_SIZE(sizeof(USED_MEM)); get_size= max(get_size, block_size); if (!(next = (USED_MEM*) my_malloc(get_size,MYF(MY_WME)))) { if (mem_root->error_handler) (*mem_root->error_handler)(); return((gptr) 0); /* purecov: inspected */ } mem_root->block_num++; next->next= *prev; next->size= get_size; next->left= get_size-ALIGN_SIZE(sizeof(USED_MEM)); *prev=next; }
开发者ID:OPSF,项目名称:uClinux,代码行数:56,
示例9: rx_tcd_init/* Initialize the Rx Transmit Control Discriptor parameters*/static void rx_tcd_init(struct tdm_priv *priv){ int i; u32 iter; u32 offset; dma_addr_t physaddr; int bytes_in_fifo_per_frame = ALIGN_SIZE(priv->cfg.num_ch * priv->cfg.ch_width, 8); iter = bytes_in_fifo_per_frame / 8 * priv->cfg.num_frames; for (i = 0; i < NUM_OF_TDM_BUF; i++) { /* TDM RX fifo address */ priv->dma_rx_tcd[i]->tcd[0] = TDM_RDR_OFFSET + priv->ptdm_base; /* ssize=dsize=64bit, soff=smod=dmod=0 */ priv->dma_rx_tcd[i]->tcd[1] = DMA_TCD1_SSIZE(SSIZE_64BITS) | DMA_TCD1_DSIZE(SSIZE_64BITS); /* number of bytes for minor loop, wide fifo 8bytes for dma */ priv->dma_rx_tcd[i]->tcd[2] = 8; /* slast = 0 */ priv->dma_rx_tcd[i]->tcd[3] = 0; offset = i * priv->cfg.num_frames * bytes_in_fifo_per_frame; /* dadr = rx buffer address */ priv->dma_rx_tcd[i]->tcd[4] = priv->dma_input_paddr + offset; /* channel to channel linking is disabled , * destination offset is inc destination adr by 8, * current iteration(citer) = number of transfers for frame */ priv->dma_rx_tcd[i]->tcd[5] = DMA_TCD5_DOFF(0x08) | DMA_TCD5_CITER_DISABLE_LINK(iter); /* enable scater gather, interrupt on 1 Frame, */ priv->dma_rx_tcd[i]->tcd[7] = DMA_TCD7_BITER_DISABLE_LINK(iter) | DMA_TCD7_E_SG | DMA_TCD7_INT_MAJ; priv->dma_rx_tcd[i]->tcd[6] = 0; } /* Next TCD for SG operation */ physaddr = priv->dma_rx_tcd_paddr; priv->dma_rx_tcd[2]->tcd[6] = ALIGN_SIZE(physaddr, ALIGNED_32_BYTES); physaddr += TCD_BUFFER_SIZE; priv->dma_rx_tcd[0]->tcd[6] = ALIGN_SIZE(physaddr, ALIGNED_32_BYTES); physaddr += TCD_BUFFER_SIZE; priv->dma_rx_tcd[1]->tcd[6] = ALIGN_SIZE(physaddr, ALIGNED_32_BYTES);}
开发者ID:DavionKnight,项目名称:H18CE-1604C,代码行数:56,
示例10: sizeofDataList::Head *DataList::Alloc(void *data, int data_size, int need_size){ Head *cur = NULL; int alloc_size = need_size + sizeof(Head); alloc_size = ALIGN_SIZE(alloc_size, 8); if (!top) { cur = top = end = (Head *)buf.Buf(); cur->next = cur->prior = NULL; } else { if (top >= end) { cur = (Head *)((BYTE *)top + top->alloc_size); if ((BYTE *)cur + alloc_size < buf.Buf() + buf.MaxSize()) { int need_grow = (int)(((BYTE *)cur + alloc_size) - (buf.Buf() + buf.Size())); if (need_grow > 0) { if (!buf.Grow(ALIGN_SIZE(need_grow, PAGE_SIZE))) { MessageBox(0, "can't alloc mem", "", MB_OK); goto END; } } } else { if ((BYTE *)end < buf.Buf() + alloc_size) { // for debug MessageBox(0, "buf is too small", "", MB_OK); goto END; } cur = (Head *)buf.Buf(); } } else { if ((BYTE *)end < (BYTE *)top + top->alloc_size + alloc_size) { // for debug MessageBox(0, "buf is too small2", "", MB_OK); goto END; } cur = (Head *)((BYTE *)top + top->alloc_size); } top->next = cur; cur->prior = top; cur->next = NULL; top = cur; } cur->alloc_size = alloc_size; cur->data_size = data_size; if (data) { memcpy(cur->data, data, data_size); } buf.AddUsedSize(alloc_size); num++;END: return cur;}
开发者ID:BrunoReX,项目名称:fastcopy,代码行数:54,
示例11: my_direndvoid my_dirend(MY_DIR *buffer){ DBUG_ENTER("my_dirend"); if (buffer) { delete_dynamic((DYNAMIC_ARRAY*)((char*)buffer + ALIGN_SIZE(sizeof(MY_DIR)))); free_root((MEM_ROOT*)((char*)buffer + ALIGN_SIZE(sizeof(MY_DIR)) + ALIGN_SIZE(sizeof(DYNAMIC_ARRAY))), MYF(0)); my_free(buffer); } DBUG_VOID_RETURN;} /* my_dirend */
开发者ID:Springlin,项目名称:david-mysql-tools,代码行数:13,
示例12: free_rootvoid free_root(MEM_ROOT *root, myf MyFlags){ reg1 USED_MEM *next,*old; DBUG_ENTER("free_root"); if (!root) DBUG_VOID_RETURN; /* purecov: inspected */ if (!(MyFlags & MY_KEEP_PREALLOC)) root->pre_alloc=0; for ( next=root->used; next ;) { old=next; next= next->next ; if (old != root->pre_alloc) my_free((gptr) old,MYF(0)); } for (next= root->free ; next ; ) { old=next; next= next->next ; if (old != root->pre_alloc) my_free((gptr) old,MYF(0)); } root->used=root->free=0; if (root->pre_alloc) { root->free=root->pre_alloc; root->free->left=root->pre_alloc->size-ALIGN_SIZE(sizeof(USED_MEM)); root->free->next=0; } DBUG_VOID_RETURN;}
开发者ID:dparnell,项目名称:MariaDB,代码行数:31,
示例13: check_ptrstatic int check_ptr(const char *where, uchar *ptr, const char *filename, uint lineno){ if (!ptr) { fprintf(stderr, "Error: %s NULL pointer at line %d, '%s'/n", where,lineno, filename); DBUG_PRINT("safe",("Null pointer at line %d '%s'", lineno, filename)); (void) fflush(stderr); return 1; }#ifndef _MSC_VER if ((long) ptr & (ALIGN_SIZE(1)-1)) { fprintf(stderr, "Error: %s wrong aligned pointer at line %d, '%s'/n", where,lineno, filename); DBUG_PRINT("safe",("Wrong aligned pointer at line %d, '%s'", lineno,filename)); (void) fflush(stderr); return 1; }#endif if (ptr < sf_min_adress || ptr > sf_max_adress) { fprintf(stderr, "Error: %s pointer out of range at line %d, '%s'/n", where,lineno, filename); DBUG_PRINT("safe",("Pointer out of range at line %d '%s'", lineno,filename)); (void) fflush(stderr); return 1; } return 0;}
开发者ID:GRMrGecko,项目名称:MGMDB,代码行数:33,
示例14: bf_malloc//No. 2 Best fit algorithm void * bf_malloc(size_t size){ t_block b,last;//,size_of_whole_block; size_t s; s = ALIGN_SIZE(size, sizeof(char*)); //size_of_used_block += size; if (base){ //find the best block last = base; b = find_best_block (&last, s); //size_of_whole_block=last; if (b){ // size_of_whole_block->size += b->size; //is it big enough to be split if ((b->size - s)>= (BLOCK_SIZE + 4 )) split_block (b,s); b->free = 0;//mark the chunk as used } else {//otherwise we extend the heap(NO FITTING BLOCK ) b = extend_heap(last,s); if (!b) return NULL; } } else {//Heap is empty (first time allocation) b = extend_heap(NULL,s); if(!b) return(NULL); base = b; } //size_of_whole_block->size += b->size; head = b; return (b-> data);}
开发者ID:Davodu,项目名称:my_malloc,代码行数:33,
示例15: rt2x00queue_payload_alignvoid rt2x00queue_payload_align(struct sk_buff *skb, bool l2pad, unsigned int header_length){ struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb); unsigned int frame_length = skb->len; unsigned int align = ALIGN_SIZE(skb, header_length); if (!align) return; if (l2pad) { if (skbdesc->flags & SKBDESC_L2_PADDED) { /* Remove L2 padding */ memmove(skb->data + align, skb->data, header_length); skb_pull(skb, align); skbdesc->flags &= ~SKBDESC_L2_PADDED; } else { /* Add L2 padding */ skb_push(skb, align); memmove(skb->data, skb->data + align, header_length); skbdesc->flags |= SKBDESC_L2_PADDED; } } else { /* Generic payload alignment to 4-byte boundary */ skb_push(skb, align); memmove(skb->data, skb->data + align, frame_length); }}
开发者ID:AppEngine,项目名称:linux-2.6,代码行数:28,
示例16: BCMATTACHFN/* * bcm_mpm_get_obj_size() - The size of memory objects may need to be padded to * compensate for alignment requirements of the objects. * This function provides the padded object size. If clients * pre-allocate a memory slab for a memory pool, the * padded object size should be used by the client to allocate * the memory slab (in order to provide sufficent space for * the maximum number of objects). * * Parameters: * mgr: INPUT The handle to the pools manager. * obj_sz: INPUT Input object size. * padded_obj_sz: OUTPUT Padded object size. * * Returns: * BCME_OK Ok * BCME_BADARG Bad arguments. * */int BCMATTACHFN(bcm_mpm_get_obj_size)(bcm_mpm_mgr_h mgr, unsigned int obj_sz, unsigned int *padded_obj_sz){ UNUSED_PARAMETER(mgr); /* Check parameters */ if (obj_sz == 0) { return (BCME_BADARG); } /* A linked-list of free memory objects is maintained by the memory pool. * While free, the contents of the memory object body itself is used for the * linked-list pointers. (Therefore no per-memory-object meta-data is * maintained). * * If the requested memory object size is less than the size of free-list * pointer, pad the object size. * * Also, if the requested memory object size is not pointer aligned, pad * the object size so that the "next" free-list pointers are aligned correctly. */ if (obj_sz < sizeof(bcm_mp_free_list_t)) { *padded_obj_sz = sizeof(bcm_mp_free_list_t); } else { *padded_obj_sz = ALIGN_SIZE(obj_sz, sizeof(void*)); } return (BCME_OK);}
开发者ID:Hosting-Scripts,项目名称:asuswrt-merlin,代码行数:50,
示例17: wf_mallocvoid * wf_malloc (size_t size){ t_block b, last;//, size_of_whole_block; size_t s; //aligning the requested size using the macro defined in my_malloc.h s = ALIGN_SIZE(size, sizeof(char*)); //if base is initialized, we can proceed to implement malloc //size_of_used_block += size; if(base){ //first find a block last = base; b = find_worst_block (&last,s); //size_of_whole_block=last; if (b){ // size_of_whole_block->size += b->size; //is it big enough to be split if((b->size - s)>= (BLOCK_SIZE + 4 )) split_block (b,s); b->free = 0;//mark the chunk as used } else {//otherwise we extend the heap(NO FITTING BLOCK ) b = extend_heap(last,s); if (!b) return NULL; } } else {//Heap is empty (first time allocation) b = extend_heap(NULL,s); if(!b) return(NULL); base = b; } //size_of_whole_block->size += b->size; head = b; return (b->data);}
开发者ID:Davodu,项目名称:my_malloc,代码行数:34,
示例18: tdm_fsl_starlite_readstatic u32 tdm_fsl_starlite_read(struct tdm_adapter *adap, u16 **input_tdm_buffer){ struct tdm_priv *priv = tdm_get_adapdata(adap); u8 phase_rx; u32 buf_addr, buf_size; /* point to where to start for the current phase data processing */ int bytes_in_fifo_per_frame = ALIGN_SIZE(priv->cfg.num_ch * priv->cfg.ch_width, 8); if (priv->tdm_active == 0) { dev_warn(priv->device, "TDM is not ready"); return 0; } if (priv->phase_rx == 0) phase_rx = NUM_OF_TDM_BUF - 1; else phase_rx = priv->phase_rx - 1; buf_size = bytes_in_fifo_per_frame * priv->cfg.num_frames; buf_addr = buf_size * phase_rx; *input_tdm_buffer = (u16 *)(priv->tdm_input_data + buf_addr); return buf_size;}
开发者ID:DavionKnight,项目名称:H18CE-1604C,代码行数:26,
示例19: tdm_fsl_starlite_get_write_bufstatic u32 tdm_fsl_starlite_get_write_buf(struct tdm_adapter *adap, u16 **output_tdm_buffer){ struct tdm_priv *priv = tdm_get_adapdata(adap); u32 tmp; u8 phase_tx; u32 buf_addr, buf_size; /* point to where to start for the current phase data processing */ int bytes_in_fifo_per_frame = ALIGN_SIZE(priv->cfg.num_ch * priv->cfg.ch_width, 8); if (priv->tdm_active == 0) { dev_warn(priv->device, "TDM is not ready"); return 0; } tmp = in_be32(&priv->dmac_regs->tcd[TDMTX_DMA_CH].tcd[0]); tmp -= priv->dma_tx_tcd[0]->tcd[0]; priv->phase_tx = tmp / (bytes_in_fifo_per_frame * priv->cfg.num_frames); if (priv->phase_tx == 0) phase_tx = NUM_OF_TDM_BUF - 1; else phase_tx = priv->phase_tx - 1; buf_size = bytes_in_fifo_per_frame * priv->cfg.num_frames; buf_addr = buf_size * phase_tx; *output_tdm_buffer = (u16 *)(priv->tdm_output_data + buf_addr); return buf_size;}
开发者ID:DavionKnight,项目名称:H18CE-1604C,代码行数:33,
示例20: DBUG_ENTERvoid *_mymalloc(size_t size, const char *filename, uint lineno, myf MyFlags){ struct st_irem *irem; uchar *data; DBUG_ENTER("_mymalloc"); DBUG_PRINT("enter",("Size: %lu", (ulong) size)); if (!sf_malloc_quick) (void) _sanity (filename, lineno); if (size + sf_malloc_cur_memory > sf_malloc_mem_limit) irem= 0; else { /* Allocate the physical memory */ irem= (struct st_irem *) malloc (ALIGN_SIZE(sizeof(struct st_irem)) + sf_malloc_prehunc + size + /* size requested */ 4 + /* overrun mark */ sf_malloc_endhunc); DBUG_EXECUTE_IF("simulate_out_of_memory", { free(irem); irem= NULL; });
开发者ID:ystk,项目名称:debian-mysql-5.1,代码行数:25,
示例21: allocate inline void* allocate(std::size_t sz) throw(std::bad_alloc) { sz = ALIGN_SIZE(sz, std::size_t, sizeof(aligner)); if (sz <= T_depth) { heap* h = m_head; while (h) { void* const ptr = h->allocate(sz); if (ptr) { if (h != m_head) { dlist_pop(this, h); dlist_push_head(this, h); DBG_PRINTF(("(%p/%d/%d) Dynamic Region Heap Adjust/n", (void*)h, m_depth, m_max_depth)); } return ptr; } h = h->m_next; } void* const ptr = create_heap()->allocate(sz); if (ptr) { return ptr; } } void* const ptr = std::malloc(sz); if(! ptr) { throw std::bad_alloc(); } return ptr; }
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:28,
示例22: malloc/*Firstly, the realloc judge the pointer. if the pointer points to nothing, it just simplymalloc. If the size is zero, it return null. If the size greater than 0, it judge whether the oldsize is greater than the newsize. If is, the realloc would use the previous address. If not,the realloc function would malloc a new block.*/void *realloc(void *ptr, size_t size) { if( ptr==NULL ) { return malloc(size); } if( size == 0 ){ free(ptr); return NULL; } if( size > 0 ){ size_t oldsize = GET_SIZE( ptr ); size_t newsize = ALIGN_SIZE( size + WSIZE ); if( oldsize >= newsize ){ /* newsize is less than oldsize */ /* the next block is allocated */ if( (oldsize-newsize) >= ALIGNMENT ){ /* used to miss GET_PRE_ALLOC_INFO with PRE_ALLOC_INFO*/ size_t head = 1 | GET_PRE_ALLOC_INFO(ptr) | GET_PRE_8_INFO(ptr); PUT_HDRP(ptr, PACK(newsize, head) ); size_t leftsize = oldsize - newsize; void *next = GET_NEXT(ptr); PUT_HDRP( next, PACK(leftsize, 0x2) ); PUT_FTRP( next, PACK(leftsize, 0x2) ); insert_node( coalesce(next) ); } return ptr; } else { /* newsize is greater than oldsize */ void * newptr = malloc(size); memcpy(newptr, ptr, GET_SIZE(ptr)); free(ptr); return newptr; } } return NULL; }
开发者ID:MinghanChen,项目名称:malloc_lab,代码行数:39,
示例23: _myfreevoid _myfree(void *ptr, const char *filename, uint lineno, myf myflags){ struct st_irem *irem; DBUG_ENTER("_myfree"); DBUG_PRINT("enter",("ptr: %p", ptr)); if (!sf_malloc_quick) (void) _sanity (filename, lineno); if ((!ptr && (myflags & MY_ALLOW_ZERO_PTR)) || check_ptr("Freeing",(uchar*) ptr,filename,lineno)) DBUG_VOID_RETURN; /* Calculate the address of the remember structure */ irem= (struct st_irem *) ((char*) ptr- ALIGN_SIZE(sizeof(struct st_irem))- sf_malloc_prehunc); /* Check to make sure that we have a real remember structure. Note: this test could fail for four reasons: (1) The memory was already free'ed (2) The memory was never new'ed (3) There was an underrun (4) A stray pointer hit this location */ if (*((uint32*) ((char*) ptr- sizeof(uint32))) != MAGICKEY) { fprintf(stderr, "Error: Freeing unallocated data at line %d, '%s'/n", lineno, filename); DBUG_PRINT("safe",("Unallocated data at line %d, '%s'",lineno,filename)); (void) fflush(stderr); DBUG_VOID_RETURN; } /* Remove this structure from the linked list */ pthread_mutex_lock(&THR_LOCK_malloc); if (irem->prev) irem->prev->next= irem->next; else sf_malloc_root= irem->next; if (irem->next) irem->next->prev= irem->prev; /* Handle the statistics */ sf_malloc_cur_memory-= irem->datasize; sf_malloc_count--; pthread_mutex_unlock(&THR_LOCK_malloc);#ifndef HAVE_purify /* Mark this data as free'ed */ if (!sf_malloc_quick) bfill(ptr, irem->datasize, (pchar) FREE_VAL);#endif *((uint32*) ((char*) ptr- sizeof(uint32)))= ~MAGICKEY; /* Actually free the memory */ free((char*) irem); DBUG_VOID_RETURN;}
开发者ID:GRMrGecko,项目名称:MGMDB,代码行数:59,
示例24: GetTickCountUINT __stdcall CGameUpdate::RecvThread(LPVOID lpVoid){ CGameUpdate* pThis = reinterpret_cast<CGameUpdate*>(lpVoid); DWORD dwStarTime = GetTickCount(); DWORD dwLastTime = GetTickCount(); DWORD dwTotalBytes = 0; for (std::vector<tagIdxFile*>::iterator it = pThis->m_vFiles.begin(); it != pThis->m_vFiles.end(); it++) { tagIdxFile* pFile = (*it); if ((pFile->attr & FILE_ATTRIBUTE_DIRECTORY) || (pFile->update == 0)) continue; HANDLE hFile = INVALID_HANDLE_VALUE; bool bFirstBlock = true; for (DWORD idx=0; idx<pFile->blknum; idx++) { if (!pThis->CheckState()) goto exit; tagIdxBlock* pBlock = pThis->m_vBlocks[pFile->crcoff + idx]; if (pBlock->update != 1) continue; try { pBlock->pdata = new char[ALIGN_SIZE(pBlock->blksize, 0x10000)]; } catch (...) { pThis->SetErrorInfo(UPT_ERR_INNERERR, GetLastError()); goto exit; } if (!pThis->m_Server.RecvBlock(pFile->name.c_str(), pFile->size, pBlock->offset, pBlock->blksize, bFirstBlock, pBlock->pdata, pThis->m_hExited)) { if (WaitForSingleObject(pThis->m_hExited, 0) != WAIT_OBJECT_0) pThis->SetErrorInfo(UPT_ERR_DWNFAIL, pFile->name.c_str()); Delete_Array(pBlock->pdata); goto exit; } if (!pThis->m_pipe->Push(pBlock)) { Delete_Array(pBlock->pdata); goto exit; } bFirstBlock = false; pThis->LimitSpeed(dwStarTime, dwLastTime, dwTotalBytes, pBlock->blksize); } }exit: return 0;}
开发者ID:lubing521,项目名称:important-files,代码行数:56,
示例25: my_once_allocvoid* my_once_alloc(size_t Size, myf MyFlags){ size_t get_size, max_left; uchar* point; reg1 USED_MEM *next; reg2 USED_MEM **prev; Size= ALIGN_SIZE(Size); prev= &my_once_root_block; max_left=0; for (next=my_once_root_block ; next && next->left < Size ; next= next->next) { if (next->left > max_left) max_left=next->left; prev= &next->next; } if (! next) { /* Time to alloc new block */ get_size= Size+ALIGN_SIZE(sizeof(USED_MEM)); if (max_left*4 < my_once_extra && get_size < my_once_extra) get_size=my_once_extra; /* Normal alloc */ if ((next = (USED_MEM*) malloc(get_size)) == 0) { my_errno=errno; if (MyFlags & (MY_FAE+MY_WME)) my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG+ME_FATALERROR), get_size); return((uchar*) 0); } DBUG_PRINT("test",("my_once_malloc %lu byte malloced", (ulong) get_size)); next->next= 0; next->size= get_size; next->left= get_size-ALIGN_SIZE(sizeof(USED_MEM)); *prev=next; } point= (uchar*) ((char*) next+ (next->size-next->left)); next->left-= Size; if (MyFlags & MY_ZEROFILL) memset(point, 0, Size); return((void*) point);} /* my_once_alloc */
开发者ID:bobzhen,项目名称:MySQL-Research,代码行数:42,
示例26: init_alloc_rootvoid init_alloc_root(MEM_ROOT *mem_root, size_t block_size, size_t pre_alloc_size){ mem_root->free=mem_root->used=0; mem_root->min_malloc=32; mem_root->block_size=block_size-MALLOC_OVERHEAD-sizeof(USED_MEM)-8; mem_root->error_handler=0;#if !(defined(HAVE_purify) && defined(EXTRA_DEBUG)) if (pre_alloc_size) { if ((mem_root->free = mem_root->pre_alloc= (USED_MEM*) my_malloc(pre_alloc_size+ ALIGN_SIZE(sizeof(USED_MEM)), MYF(0)))) { mem_root->free->size=pre_alloc_size+ALIGN_SIZE(sizeof(USED_MEM)); mem_root->free->left=pre_alloc_size; mem_root->free->next=0; } }#endif}
开发者ID:dparnell,项目名称:MariaDB,代码行数:20,
示例27: my_security_attr_freevoid my_security_attr_free(SECURITY_ATTRIBUTES *sa){ if (sa) { My_security_attr *attr= (My_security_attr*) (((char*)sa) + ALIGN_SIZE(sizeof(*sa))); FreeSid(attr->everyone_sid); my_free(attr->dacl); my_free(sa); }}
开发者ID:Xadras,项目名称:TBCPvP,代码行数:11,
示例28: gst_droid_media_buffer_allocator_alloc_from_bufferstatic GstDroidMediaBufferMemory *gst_droid_media_buffer_allocator_alloc_from_buffer (GstAllocator * allocator, DroidMediaBuffer * buffer, int format_index, gsize width, gsize height, gsize stride){ GstDroidMediaBufferMemory *mem = g_slice_new0 (GstDroidMediaBufferMemory); GstFormat format; gsize padded_width = width; gsize padded_height = height; mem->buffer = buffer; mem->map_data = NULL; mem->map_flags = 0; mem->map_count = 0; if (format_index == GST_DROID_MEDIA_BUFFER_FORMAT_COUNT) { format = GST_VIDEO_FORMAT_ENCODED; } else { format = gst_droid_media_buffer_formats[format_index].gst_format; if (gst_droid_media_buffer_formats[format_index].bytes_per_pixel != 0) { padded_width = ALIGN_SIZE (stride, gst_droid_media_buffer_formats[format_index].h_align) / gst_droid_media_buffer_formats[format_index].bytes_per_pixel; padded_height = ALIGN_SIZE (height, gst_droid_media_buffer_formats[format_index].v_align); } } gst_video_info_set_format (&mem->video_info, format, padded_width, padded_height); mem->video_info.width = width; mem->video_info.height = height; gst_memory_init (GST_MEMORY_CAST (mem), GST_MEMORY_FLAG_NO_SHARE, allocator, NULL, mem->video_info.size, 0, 0, mem->video_info.size); return mem;}
开发者ID:sailfishos,项目名称:gst-droid,代码行数:41,
注:本文中的ALIGN_SIZE函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ ALLEGRO_DEBUG函数代码示例 C++ ALIGN_DOWN函数代码示例 |