Skip to content

Commit

Permalink
Use snake case
Browse files Browse the repository at this point in the history
  • Loading branch information
atakagi-fixstars committed Dec 15, 2022
1 parent 9a11b29 commit 26ca73e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions src/device_allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ limitations under the License.
namespace sgm
{

DeviceAllocator::DeviceAllocator() : data_(nullptr), refCount_(nullptr), capacity_(0)
DeviceAllocator::DeviceAllocator() : data_(nullptr), ref_count_(nullptr), capacity_(0)
{
}

Expand All @@ -48,7 +48,7 @@ void* DeviceAllocator::allocate(size_t size)
{
release();
CUDA_CHECK(cudaMalloc(&data_, size));
refCount_ = new int(1);
ref_count_ = new int(1);
capacity_ = size;
}
return data_;
Expand All @@ -63,13 +63,13 @@ void DeviceAllocator::assign(void* data, size_t size)

void DeviceAllocator::release()
{
if (refCount_ && --(*refCount_) == 0)
if (ref_count_ && --(*ref_count_) == 0)
{
CUDA_CHECK(cudaFree(data_));
delete refCount_;
delete ref_count_;
}

data_ = refCount_ = nullptr;
data_ = ref_count_ = nullptr;
capacity_ = 0;
}

Expand All @@ -90,20 +90,20 @@ DeviceAllocator& DeviceAllocator::operator=(DeviceAllocator&& right)
void DeviceAllocator::copy_construct_from(const DeviceAllocator& other)
{
data_ = other.data_;
refCount_ = other.refCount_;
ref_count_ = other.ref_count_;
capacity_ = other.capacity_;

if (refCount_)
(*refCount_)++;
if (ref_count_)
(*ref_count_)++;
}

void DeviceAllocator::move_construct_from(DeviceAllocator&& right)
{
data_ = right.data_;
refCount_ = right.refCount_;
ref_count_ = right.ref_count_;
capacity_ = right.capacity_;

right.data_ = right.refCount_ = nullptr;
right.data_ = right.ref_count_ = nullptr;
right.capacity_ = 0;
}

Expand Down
2 changes: 1 addition & 1 deletion src/device_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class DeviceAllocator
void move_construct_from(DeviceAllocator&& right);

void* data_;
int* refCount_;
int* ref_count_;
size_t capacity_;
};

Expand Down

0 comments on commit 26ca73e

Please sign in to comment.