aboutsummaryrefslogtreecommitdiff
path: root/tests/sys/fs/fusefs/read.cc
diff options
context:
space:
mode:
authorAlan Somers <asomers@FreeBSD.org>2024-01-15 23:49:47 +0000
committerAlan Somers <asomers@FreeBSD.org>2024-01-17 22:49:41 +0000
commit8bae22bbbe6571da9259e0d43ffa8a56f4b3e171 (patch)
tree06f245b972713429b49c13a70d0a257bc61e498c /tests/sys/fs/fusefs/read.cc
parent78ae60b447ebf420dd5cebfec30480866fd5cef4 (diff)
downloadsrc-8bae22bbbe6571da9259e0d43ffa8a56f4b3e171.tar.gz
src-8bae22bbbe6571da9259e0d43ffa8a56f4b3e171.zip
fusefs: prefer new/delete over malloc/free
MFC after: 2 weeks Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D43464
Diffstat (limited to 'tests/sys/fs/fusefs/read.cc')
-rw-r--r--tests/sys/fs/fusefs/read.cc14
1 files changed, 6 insertions, 8 deletions
diff --git a/tests/sys/fs/fusefs/read.cc b/tests/sys/fs/fusefs/read.cc
index 3df0420facb9..373f742d4fd3 100644
--- a/tests/sys/fs/fusefs/read.cc
+++ b/tests/sys/fs/fusefs/read.cc
@@ -1216,8 +1216,7 @@ TEST_F(Read, cache_block)
char buf[bufsize];
const char *contents1 = CONTENTS0 + bufsize;
- contents = (char*)calloc(1, filesize);
- ASSERT_NE(nullptr, contents);
+ contents = new char[filesize]();
memmove(contents, CONTENTS0, strlen(CONTENTS0));
expect_lookup(RELPATH, ino, filesize);
@@ -1235,7 +1234,7 @@ TEST_F(Read, cache_block)
ASSERT_EQ(bufsize, read(fd, buf, bufsize)) << strerror(errno);
ASSERT_EQ(0, memcmp(buf, contents1, bufsize));
leak(fd);
- free(contents);
+ delete[] contents;
}
/* Reading with sendfile should work (though it obviously won't be 0-copy) */
@@ -1332,10 +1331,9 @@ TEST_P(ReadAhead, readahead) {
char *rbuf, *contents;
off_t offs;
- contents = (char*)malloc(filesize);
- ASSERT_NE(nullptr, contents);
+ contents = new char[filesize];
memset(contents, 'X', filesize);
- rbuf = (char*)calloc(1, bufsize);
+ rbuf = new char[bufsize]();
expect_lookup(RELPATH, ino, filesize);
expect_open(ino, 0, 1);
@@ -1357,8 +1355,8 @@ TEST_P(ReadAhead, readahead) {
ASSERT_EQ(0, memcmp(rbuf, contents, bufsize));
leak(fd);
- free(rbuf);
- free(contents);
+ delete[] rbuf;
+ delete[] contents;
}
INSTANTIATE_TEST_SUITE_P(RA, ReadAhead,