Skip to content

Commit

Permalink
[clang][Interp][NFC] Add std:: qualifiers to all malloc/free calls
Browse files Browse the repository at this point in the history
  • Loading branch information
tbaederr committed Jul 9, 2023
1 parent 88d65e1 commit fa1e9c3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion clang/lib/AST/Interp/InterpBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,5 @@ void DeadBlock::free() {
Next->Prev = Prev;
if (Root == this)
Root = Next;
::free(this);
std::free(this);
}
8 changes: 4 additions & 4 deletions clang/lib/AST/Interp/InterpStack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ InterpStack::~InterpStack() {

void InterpStack::clear() {
if (Chunk && Chunk->Next)
free(Chunk->Next);
std::free(Chunk->Next);
if (Chunk)
free(Chunk);
std::free(Chunk);
Chunk = nullptr;
StackSize = 0;
}
Expand All @@ -33,7 +33,7 @@ void *InterpStack::grow(size_t Size) {
if (Chunk && Chunk->Next) {
Chunk = Chunk->Next;
} else {
StackChunk *Next = new (malloc(ChunkSize)) StackChunk(Chunk);
StackChunk *Next = new (std::malloc(ChunkSize)) StackChunk(Chunk);
if (Chunk)
Chunk->Next = Next;
Chunk = Next;
Expand Down Expand Up @@ -65,7 +65,7 @@ void InterpStack::shrink(size_t Size) {
while (Size > Chunk->size()) {
Size -= Chunk->size();
if (Chunk->Next) {
free(Chunk->Next);
std::free(Chunk->Next);
Chunk->Next = nullptr;
}
Chunk->End = Chunk->start();
Expand Down
5 changes: 3 additions & 2 deletions clang/lib/AST/Interp/InterpState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ InterpState::~InterpState() {

while (DeadBlocks) {
DeadBlock *Next = DeadBlocks->Next;
free(DeadBlocks);
std::free(DeadBlocks);
DeadBlocks = Next;
}
}
Expand All @@ -54,7 +54,8 @@ void InterpState::deallocate(Block *B) {
size_t Size = B->getSize();

// Allocate a new block, transferring over pointers.
char *Memory = reinterpret_cast<char *>(malloc(sizeof(DeadBlock) + Size));
char *Memory =
reinterpret_cast<char *>(std::malloc(sizeof(DeadBlock) + Size));
auto *D = new (Memory) DeadBlock(DeadBlocks, B);

// Move data from one block to another.
Expand Down

0 comments on commit fa1e9c3

Please sign in to comment.