这篇教程C++ GET_SIZE函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中GET_SIZE函数的典型用法代码示例。如果您正苦于以下问题:C++ GET_SIZE函数的具体用法?C++ GET_SIZE怎么用?C++ GET_SIZE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了GET_SIZE函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: place/********************************************************** * place * Mark the block as allocated. * Also create a new free block of the size difference if possible. **********************************************************/void place(void* bp, size_t asize){ remove_free_block(bp); /* Get the current block size */ size_t bsize = GET_SIZE(HDRP(bp)); // Create a block of the size difference and insert it into the free list. if (bsize - asize > 8*DSIZE) { PUT(HDRP(bp), PACK(asize, 1)); PUT(FTRP(bp), PACK(asize, 1)); PUT(HDRP(NEXT_BLKP(bp)), PACK(bsize-asize, 0)); PUT(FTRP(NEXT_BLKP(bp)), PACK(bsize-asize, 0)); add_free_block(NEXT_BLKP(bp)); } else { PUT(HDRP(bp), PACK(bsize, 1)); PUT(FTRP(bp), PACK(bsize, 1)); }}
开发者ID:tabletenniser,项目名称:ECE454_hw3,代码行数:23,
示例2: whilestatic void *match( size_t asize ){ if(asize == 8 && list_for_8 != NULL_POINTER) return list_for_8; if(asize <= 16 && list_for_16 != NULL_POINTER) return list_for_16; /* the most fit block */ void *fit = NULL_POINTER; /* temporary location of the search */ void *temp = root; /* use tree to implement a comparative best fit search */ while(temp != NULL_POINTER){ if( asize <= GET_SIZE(temp) ){ fit = temp; temp = (void *)GET_LEFT(temp); } else temp = (void *)GET_RIGHT(temp); } return fit;}
开发者ID:MinghanChen,项目名称:malloc_lab,代码行数:18,
示例3: mm_free/********************************************************** * mm_free * Free the block and coalesce with neighbouring blocks **********************************************************/void mm_free(void *bp){ logg(3, "/n============ mm_free() starts =============="); if (LOGGING_LEVEL>0) mm_check(); logg(1, "mm_free() with bp: %p; header: %zx(h); footer: %zx(h)", bp, GET(HDRP(bp)), GET(FTRP(bp))); if(bp == NULL){ return; } // Mark the current block as free and do coalescing. size_t size = GET_SIZE(HDRP(bp)); PUT(HDRP(bp), PACK(size,0)); PUT(FTRP(bp), PACK(size,0)); coalesce(bp); logg(3, "============ mm_free() ends ==============/n");}
开发者ID:tabletenniser,项目名称:ECE454_hw3,代码行数:22,
示例4: placestatic void place(void *bp,size_t asize){ size_t csize = GET_SIZE(bp); delete_node( bp ); if((csize-asize) >= ALIGN_REQ){ size_t sign = 1 | GET_PRE_ALLOC_INFO(bp) | GET_PRE_8_INFO(bp); PUT_HDRP( bp,PACK(asize,sign) ); void * temp = GET_NEXT(bp); PUT_HDRP( temp, PACK(csize-asize,2) ); PUT_FTRP( temp, PACK(csize-asize,2) ); insert_node( coalesce(temp) ); } else{ size_t sign = 1 | GET_PRE_ALLOC_INFO(bp) | GET_PRE_8_INFO(bp); PUT_HDRP(bp,PACK(csize, sign) ); }}
开发者ID:MinghanChen,项目名称:malloc_lab,代码行数:18,
示例5: find_two_free_blocks/********************************************************** * free_list_marked_as_free * check if there are two consecutive free blocks in the * heap * we start at second block and check if previous one is * free, if current block is free *********************************************************/int find_two_free_blocks(void){ void *bp; if (heap_listp == NULL) return 1; //no blocks if (NEXT_BLKP(heap_listp) == NULL) return 1; //only one block for (bp = NEXT_BLKP(heap_listp); GET_SIZE(HDRP(bp)) > 0; bp = NEXT_BLKP(bp)) { if (!GET_ALLOC(HDRP(bp))) { if (!GET_ALLOC(PREV_BLKP(bp))) { return 0; } } } return 1;}
开发者ID:bkashyap,项目名称:ece454,代码行数:25,
示例6: place/* Place block of asize bytes at start of free block bp and split if remainder would be at least minimum block size the requested size of free block */static void place(void *bp, size_t asize){ size_t csize = GET_SIZE(bp); if ((csize - asize) >= BLKSIZE) { SET_HDRP(bp, PACK(asize, 1)); SET_FTRP(bp, PACK(asize, 1)); mm_delete(bp); bp = NEXT_BLKP(bp); SET_HDRP(bp, PACK(csize-asize, 0)); SET_FTRP(bp, PACK(csize-asize, 0)); coalesce(bp); } else { SET_HDRP(bp, PACK(csize, 1)); SET_FTRP(bp, PACK(csize, 1)); mm_delete(bp); }}
开发者ID:fast1234,项目名称:Dynamic-Memory-Allocator,代码行数:22,
示例7: mm_free/* $begin mmfree */void mm_free(void *bp){/* $end mmfree */ if(bp == 0) return;/* $begin mmfree */ size_t size = GET_SIZE(HDRP(bp));/* $end mmfree */ if (heap_listp == 0){ mm_init(); }/* $begin mmfree */ PUT(HDRP(bp), PACK(size, 0)); PUT(FTRP(bp), PACK(size, 0)); coalesce(bp);}
开发者ID:illucination3782,项目名称:6-malloc,代码行数:19,
|