Skip to content

Commit

Permalink
libpressio version 0.30.1
Browse files Browse the repository at this point in the history
Bug Fixes:

+ pressio_metrics objects are now default, move, and copy construct able
+ pressio_data objects no longer attempt to copy from empty objects
  which previously caused seg faults
  • Loading branch information
robertu94 committed Jan 23, 2020
1 parent d65fd19 commit be346c9
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
project(libpressio VERSION "0.30.0" LANGUAGES CXX C)
project(libpressio VERSION "0.30.1" LANGUAGES CXX C)

#correct was to set a default build type
# https://blog.kitware.com/cmake-and-the-default-build-type/
Expand Down
2 changes: 1 addition & 1 deletion COPYRIGHT.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Copyright © 2020 , UChicago Argonne, LLC
All Rights Reserved
[libpressio, Version 0.30.0]
[libpressio, Version 0.30.1]
Robert Underwood
Argonne National Laboratory

Expand Down
14 changes: 10 additions & 4 deletions include/libpressio_ext/cpp/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,12 @@ struct pressio_data {
pressio_data& operator=(pressio_data const& rhs) {
if(this == &rhs) return *this;
data_dtype = rhs.data_dtype;
data_ptr = malloc(rhs.size_in_bytes());
memcpy(data_ptr, rhs.data_ptr, rhs.size_in_bytes());
if(rhs.has_data()) {
data_ptr = malloc(rhs.size_in_bytes());
memcpy(data_ptr, rhs.data_ptr, rhs.size_in_bytes());
} else {
data_ptr = nullptr;
}
metadata_ptr = nullptr;
deleter = pressio_data_libc_free_fn;
dims = rhs.dims;
Expand All @@ -230,12 +234,14 @@ struct pressio_data {
* */
pressio_data(pressio_data const& rhs):
data_dtype(rhs.data_dtype),
data_ptr(malloc(rhs.size_in_bytes())),
data_ptr(rhs.has_data()? malloc(rhs.size_in_bytes()) : nullptr),
metadata_ptr(nullptr),
deleter(pressio_data_libc_free_fn),
dims(rhs.dims)
{
memcpy(data_ptr, rhs.data_ptr, rhs.size_in_bytes());
if(rhs.has_data()) {
memcpy(data_ptr, rhs.data_ptr, rhs.size_in_bytes());
}
}
/**
* move-constructor
Expand Down
20 changes: 20 additions & 0 deletions include/libpressio_ext/cpp/metrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,26 @@ struct pressio_metrics {
/** construct a metrics wrapper*/
pressio_metrics(std::unique_ptr<libpressio_metrics_plugin>&& metrics): plugin(std::move(metrics)) {}

/** allow default construction*/
pressio_metrics()=default;
/**
* move construct a metric from another pointer
*/
pressio_metrics(pressio_metrics const& metrics)=default;
/**
* move assigns a metric from another pointer
*/
pressio_metrics& operator=(pressio_metrics const& metrics)=default;
/**
* move construct a metric from another pointer
*/
pressio_metrics(pressio_metrics&& metrics)=default;
/**
* move assigns a metric from another pointer
*/
pressio_metrics& operator=(pressio_metrics&& metrics)=default;


/** allow access to underlying plugin*/
libpressio_metrics_plugin* operator->() const noexcept {return plugin.get();}
/** allow access to underlying plugin*/
Expand Down

0 comments on commit be346c9

Please sign in to comment.