【发布时间】:2014-04-13 09:48:47
【问题描述】:
这个函数在我的程序中被调用:
int cal_addr(long file_size , long* block, file* isfile,unsigned long block_size;) {
long double tmp = (long double) file_size/block_size;
*block = ceil (tmp ) ;
int start = us.alloc_index ; // us.alloc_index is int
int fd = fs.tot_alloc_file ; // fs.tot_alloc_file is int
int blk = *((int*)block) ;
size_t s = (blk) * sizeof(int) ;
// us.usage is global array of integers
memset(& (us.usage[start] ), fd , s);
us.alloc_index = us.alloc_index + (*block) ;
isfile->end_addr_usage = us.alloc_index;
return 1 ;
}
// gdb 的输出如下。当我打印时,我看到 fd 值仍然为 1 us.usage[202] 的元素,例如它具有这个奇怪的值。不是我期望的 1 个
(gdb) p us.usage[202]
$3 = 16843009
(gdb) p fd
$5 = 1
(gdb)
【问题讨论】:
标签: c memory memory-management memory-leaks memset