我定义了这个函数:
struct heap_validation {
size_t num_alloc;
size_t num_alloc_sz;
struct memory *mem;
};
...
bool get_isallocated(struct metadata_record *);
当我从 hashtable_traverse 调用 heap_validation 函数并打印结果时,我得到了以下值: 0,255 ,246
void hashtable_traverse(struct metadata_record *metarec,
struct heap_validation *heap_val) {
printf("get_isallocated(metarec): %d\n",get_isallocated(metarec));
bool retrieved = false;
bool allocated = get_isallocated(metarec);
if (allocated) {
heap_val->num_alloc += 1;
我也尝试了 %d 并且得到了相同的结果。