Skip to content

Commit

Permalink
Fix Raith data memory leak
Browse files Browse the repository at this point in the history
Signed-off-by: Lucas Heitzmann Gabrielli <[email protected]>
  • Loading branch information
heitzmann committed Aug 31, 2024
1 parent 64083fd commit 69fbde1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion include/gdstk/raithdata.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct RaithData {

void copy_from(const RaithData& raith_data);

PXXData to_pxxdata() const;
PXXData to_pxxdata(double scaling) const;
void from_pxxdata(PXXData const& pxxdata);
};

Expand Down
2 changes: 1 addition & 1 deletion src/flexpath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ ErrorCode FlexPath::to_gds(FILE* out, double scaling) {
8,
0x0F03};

PXXData pxxdata = raith_data.to_pxxdata();
PXXData pxxdata = raith_data.to_pxxdata(scaling);
pxxdata.little_endian_swap();

uint64_t len = raith_data.base_cell_name ? strlen(raith_data.base_cell_name) : 0;
Expand Down
9 changes: 5 additions & 4 deletions src/raithdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,16 @@ void RaithData::copy_from(const RaithData& raith_data) {
dots_per_cycle = raith_data.dots_per_cycle;
dwelltime_selection = raith_data.dwelltime_selection;
if (base_cell_name) free_allocation(base_cell_name);
base_cell_name = NULL;
if (raith_data.base_cell_name) base_cell_name = copy_string(raith_data.base_cell_name, NULL);
}

PXXData RaithData::to_pxxdata() const {
PXXData RaithData::to_pxxdata(double scaling) const {
PXXData pd{};
pd.dwelltime_selection = dwelltime_selection;
pd.pitch_parallel_to_path = pitch_parallel_to_path;
pd.pitch_perpendicular_to_path = pitch_perpendicular_to_path;
pd.pitch_scale = pitch_scale;
pd.pitch_parallel_to_path = pitch_parallel_to_path * scaling;
pd.pitch_perpendicular_to_path = pitch_perpendicular_to_path * scaling;
pd.pitch_scale = pitch_scale * scaling;
pd.periods = periods;
pd.grating_type = grating_type;
pd.dots_per_cycle = dots_per_cycle;
Expand Down

0 comments on commit 69fbde1

Please sign in to comment.