Skip to content

Commit 4910525

Browse files
committed
Add rules for operator new and delete
1 parent b5dd144 commit 4910525

3 files changed

Lines changed: 50 additions & 0 deletions

File tree

‎rules/new/src.cpp‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright (c) 2022-present INESC-ID.
2+
// Distributed under the MIT license that can be found in the LICENSE file.
3+
4+
#include <new>
5+
6+
void *f1(std::size_t a0) { return ::operator new(a0); }
7+
8+
void f2(void *a0) { return ::operator delete(a0); }
9+
10+
void *f3(std::size_t a0) { return ::operator new[](a0); }
11+
12+
void f4(void *a0) { return ::operator delete[](a0); }

‎rules/new/tgt_refcount.rs‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright (c) 2022-present INESC-ID.
2+
// Distributed under the MIT license that can be found in the LICENSE file.
3+
4+
use libcc2rs::*;
5+
6+
fn f1(a0: usize) -> AnyPtr {
7+
libcc2rs::malloc_refcount(a0)
8+
}
9+
10+
fn f2(a0: AnyPtr) {
11+
libcc2rs::free_refcount(a0)
12+
}
13+
14+
fn f3(a0: usize) -> AnyPtr {
15+
libcc2rs::malloc_refcount(a0)
16+
}
17+
18+
fn f4(a0: AnyPtr) {
19+
libcc2rs::free_refcount(a0)
20+
}

‎rules/new/tgt_unsafe.rs‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) 2022-present INESC-ID.
2+
// Distributed under the MIT license that can be found in the LICENSE file.
3+
4+
unsafe fn f1(a0: usize) -> *mut ::libc::c_void {
5+
libcc2rs::malloc_unsafe(a0)
6+
}
7+
8+
unsafe fn f2(a0: *mut ::libc::c_void) {
9+
libcc2rs::free_unsafe(a0)
10+
}
11+
12+
unsafe fn f3(a0: usize) -> *mut ::libc::c_void {
13+
libcc2rs::malloc_unsafe(a0)
14+
}
15+
16+
unsafe fn f4(a0: *mut ::libc::c_void) {
17+
libcc2rs::free_unsafe(a0)
18+
}

0 commit comments

Comments
 (0)