Skip to content

[CF] Avoid using malloc introspection. #2626

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CoreFoundation/Collections.subproj/CFBasicHash.c
Original file line number Diff line number Diff line change
Expand Up @@ -1442,6 +1442,7 @@ CF_PRIVATE size_t CFBasicHashGetSize(CFConstBasicHashRef ht, Boolean total) {
if (ht->bits.keys_offset) size += sizeof(CFBasicHashValue *);
if (ht->bits.counts_offset) size += sizeof(void *);
if (__CFBasicHashHasHashCache(ht)) size += sizeof(uintptr_t *);
#if ENABLE_MEMORY_COUNTERS || ENABLE_DTRACE_PROBES
if (total) {
CFIndex num_buckets = __CFBasicHashTableSizes[ht->bits.num_buckets_idx];
if (0 < num_buckets) {
Expand All @@ -1451,6 +1452,9 @@ CF_PRIVATE size_t CFBasicHashGetSize(CFConstBasicHashRef ht, Boolean total) {
if (__CFBasicHashHasHashCache(ht)) size += malloc_size(__CFBasicHashGetHashes(ht));
}
}
#else
(void)total;
#endif
return size;
}

Expand Down
15 changes: 0 additions & 15 deletions CoreFoundation/Collections.subproj/CFStorage.c
Original file line number Diff line number Diff line change
Expand Up @@ -1366,21 +1366,6 @@ static void __CFStorageApplyNodeBlock(CFStorageRef storage, void (^block)(CFStor
__CFStorageApplyNodeBlockInterior(storage, &storage->rootNode, block);
}

static CFIndex __CFStorageEstimateTotalAllocatedSize(CFStorageRef storage) __attribute__((unused));
static CFIndex __CFStorageEstimateTotalAllocatedSize(CFStorageRef storage) {
__block CFIndex nodeResult = 0;
__block CFIndex contentsResult = 0;
__CFStorageApplyNodeBlock(storage, ^(CFStorageRef storage, CFStorageNode *node) {
if (node != &storage->rootNode) {
nodeResult += malloc_size(node);
if (node->isLeaf && node->info.leaf.memory != NULL) {
contentsResult += malloc_size(node->info.leaf.memory);
}
}
});
return nodeResult + contentsResult;
}

void __CFStorageSetAlwaysFrozen(CFStorageRef storage, bool alwaysFrozen) {
storage->alwaysFrozen = alwaysFrozen;
}
Expand Down