Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
yuxihu committed Mar 21, 2019
1 parent 02a0fec commit d9396da
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 18 deletions.
5 changes: 2 additions & 3 deletions src/storage/cpu_device_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,12 @@ class CPUDeviceStorage {
public:
/*!
* \brief Aligned allocation on CPU.
* \param size Size to allocate.
* \return Pointer to the storage.
* \param handle Handle struct.
*/
inline static void* Alloc(Storage::Handle* handle);
/*!
* \brief Deallocation.
* \param ptr Pointer to deallocate.
* \param handle Handle struct.
*/
inline static void Free(Storage::Handle handle);

Expand Down
5 changes: 2 additions & 3 deletions src/storage/gpu_device_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,12 @@ class GPUDeviceStorage {
public:
/*!
* \brief Allocation.
* \param size Size to allocate.
* \return Pointer to the storage.
* \param handle Handle struct.
*/
inline static void* Alloc(Storage::Handle* handle);
/*!
* \brief Deallocation.
* \param ptr Pointer to deallocate.
* \param handle Handle struct.
*/
inline static void Free(Storage::Handle handle);
}; // class GPUDeviceStorage
Expand Down
5 changes: 2 additions & 3 deletions src/storage/pinned_memory_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,13 @@ class PinnedMemoryStorage {
public:
/*!
* \brief Allocation.
* \param size Size to allocate.
* \return Pointer to the storage.
* \param handle Handle struct.
*/
inline static void* Alloc(Storage::Handle* handle);

/*!
* \brief Deallocation.
* \param ptr Pointer to deallocate.
* \param handle Handle struct.
*/
inline static void Free(Storage::Handle handle);
};
Expand Down
6 changes: 4 additions & 2 deletions src/storage/storage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ void StorageImpl::Alloc(Storage::Handle* handle) {
}

void StorageImpl::Free(Storage::Handle handle) {
// Do nothing if dtpr is nullptr.
// Do nothing if dtpr is nullptr because the handle may have already
// been freed or have not been allocated memory yet.
if (handle.dptr == nullptr) return;

const Context &ctx = handle.ctx;
Expand All @@ -143,7 +144,8 @@ void StorageImpl::Free(Storage::Handle handle) {
}

void StorageImpl::DirectFree(Storage::Handle handle) {
// Do nothing if dtpr is nullptr.
// Do nothing if dtpr is nullptr because the handle may have already
// been freed or have not been allocated memory yet.
if (handle.dptr == nullptr) return;

const Context &ctx = handle.ctx;
Expand Down
11 changes: 4 additions & 7 deletions src/storage/storage_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,17 @@ class StorageManager {
public:
/*!
* \brief Allocation.
* \param size Size to allocate.
* \return Pointer to the storage.
* \param handle Handle struct.
*/
virtual void Alloc(Storage::Handle* handle) = 0;
/*!
* \brief Deallocation.
* \param ptr Pointer to deallocate.
* \param size Size of the storage.
* \param handle Handle struct.
*/
virtual void Free(Storage::Handle handle) = 0;
/*!
* \brief Direct de-allocation.
* \param ptr Pointer to deallocate.
* \param size Size of the storage.
* \brief Direct deallocation.
* \param handle Handle struct.
*/
virtual void DirectFree(Storage::Handle handle) = 0;
/*!
Expand Down

0 comments on commit d9396da

Please sign in to comment.