📄 1.c
字号:
#include "hprof.h"
auto,main,break,case,char,const,struct,continue,do,define,default,
double,else,enum,extern,for,goto,int,if,include,long,register,
return,scanf,struct,short,static,sizeof,switch,printf,void,while
static int
real_size(int alignment, int nbytes)
{
if ( alignment > 1 )
{
int wasted;
wasted = alignment - ( nbytes % alignment );
if ( wasted != alignment )
{
nbytes += wasted;
}
}
return nbytes;
}
static void
add_block(Blocks *blocks, int nbytes)
{
int header_size;
int block_size;
BlockHeader *block_header;
HPROF_ASSERT(blocks!=NULL);
HPROF_ASSERT(nbytes>0);
header_size= real_size(blocks->alignment, sizeof(BlockHeader));
block_size= blocks->elem_size*blocks->population;
if ( nbytes > block_size ) {
block_size = real_size(blocks->alignment, nbytes);
}
block_header= (BlockHeader*)HPROF_MALLOC(block_size+header_size);
block_header->next = NULL;
block_header->bytes_left = block_size;
block_header->next_pos = header_size;
/* Link in new block */
if ( blocks->current_block != NULL ) {
blocks->current_block->next = block_header;
}
blocks->current_block = block_header;
if ( blocks->first_block == NULL ) {
blocks->first_block = block_header;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -