Skip to content

Commit

Permalink
修改第二课
Browse files Browse the repository at this point in the history
  • Loading branch information
zjhellofss committed Jun 22, 2024
1 parent e43d937 commit 58ca115
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions kuiper/source/base/buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Buffer::Buffer(size_t byte_size, std::shared_ptr<DeviceAllocator> allocator, voi
Buffer::~Buffer() {
if (!use_external_) {
if (ptr_ && allocator_) {
LOG(INFO) << "Release...";
allocator_->release(ptr_);
ptr_ = nullptr;
}
Expand Down
10 changes: 7 additions & 3 deletions test/test_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@
#include <gtest/gtest.h>
#include "base/buffer.h"

TEST(test_buffer, allocate) {


TEST(test_buffer, allocate2) {
using namespace base;
auto alloc = base::CPUDeviceAllocatorFactory::get_instance();
Buffer buffer(32, alloc);
ASSERT_NE(buffer.ptr(), nullptr);
std::shared_ptr<Buffer> buffer;
{ buffer = std::make_shared<Buffer>(32, alloc); }
LOG(INFO) << "HERE";
ASSERT_NE(buffer->ptr(), nullptr);
}

TEST(test_buffer, use_external) {
Expand Down

0 comments on commit 58ca115

Please sign in to comment.