Skip to content

Commit

Permalink
Converted almost all dangerous char buffers to std::string
Browse files Browse the repository at this point in the history
Some cases were left because of the specific context they were used in. Future refactor may change that.
  • Loading branch information
CodeByDrescher committed Jan 18, 2024
1 parent 43e7104 commit 8612a09
Show file tree
Hide file tree
Showing 10 changed files with 187 additions and 161 deletions.
4 changes: 2 additions & 2 deletions VCell/include/VCELL/FVDataSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class Variable;
class FVDataSet
{
public:
static void read(char *filename, Simulation *sim);
static void write(char *filename, SimulationExpression *sim, bool bCompress);
static void read(const char *filename, Simulation *sim);
static void write(const char *filename, SimulationExpression *sim, bool bCompress);
static void convolve(Simulation* sim, Variable* var, double* values);
static void readRandomVariables(char* filename, SimulationExpression* sim);
};
Expand Down
1 change: 1 addition & 0 deletions VCell/include/VCELL/PostProcessingHdf5Writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class PostProcessingHdf5Writer
{
public:
PostProcessingHdf5Writer(char* fileName, PostProcessingBlock* postProcessingBlock);
PostProcessingHdf5Writer(std::string fileName, PostProcessingBlock* postProcessingBlock);
virtual ~PostProcessingHdf5Writer();

void writeOutput();
Expand Down
1 change: 1 addition & 0 deletions VCell/include/VCELL/SimTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class SimTool {
void updateLog(double progress,double time,int iteration);
void clearLog();
int getZipCount(char* zipFileName);
int getZipCount(const std::string* zipFileName);
void start1();
void copyParticleCountsToConcentration();

Expand Down
4 changes: 2 additions & 2 deletions VCell/include/VCELL/Simulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ class Simulation
virtual void advanceTimeOn();
virtual void advanceTimeOff();

virtual void writeData(char *filename, bool bCompress)=0;
virtual void readData(char *filename);
virtual void writeData(const char *filename, bool bCompress)=0;
virtual void readData(const char *filename);

Variable* getVariable(int index);

Expand Down
2 changes: 1 addition & 1 deletion VCell/include/VCELL/SimulationExpression.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class SimulationExpression : public Simulation
void advanceTimeOn();
void advanceTimeOff();

void writeData(char *filename, bool bCompress);
void writeData(const char *filename, bool bCompress);

void addFieldData(FieldData* fd) {
fieldDataList.push_back(fd);
Expand Down
4 changes: 2 additions & 2 deletions VCell/src/FVDataSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ static string extractVarNameFromQualifiedName(char* varName) {
return str;
}

void FVDataSet::read(char *filename, Simulation *sim)
void FVDataSet::read(const char *filename, Simulation *sim)
{
FILE *fp=NULL;
FileHeader fileHeader;
Expand Down Expand Up @@ -267,7 +267,7 @@ void FVDataSet::convolve(Simulation* sim, Variable* var, double* values) {
}
}

void FVDataSet::write(char *filename, SimulationExpression *sim, bool bCompress)
void FVDataSet::write(const char *filename, SimulationExpression *sim, bool bCompress)
{
FILE *fp=NULL;
FileHeader fileHeader;
Expand Down
8 changes: 8 additions & 0 deletions VCell/src/PostProcessingHdf5Writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <H5Cpp.h>
#include <iostream>
#include <fstream>
#include <utility>
using std::cout;
using std::endl;
#include <sys/stat.h>
Expand All @@ -27,6 +28,13 @@ PostProcessingHdf5Writer::PostProcessingHdf5Writer(char* fileName, PostProcessin
timesDataSet = NULL;
}

PostProcessingHdf5Writer::PostProcessingHdf5Writer(std::string fileName, PostProcessingBlock* ppb) {
this->h5PPFileName = std::move(fileName);
this->postProcessingBlock = ppb;
h5PPFile = NULL;
timesDataSet = NULL;
}

PostProcessingHdf5Writer::~PostProcessingHdf5Writer() {
delete timesDataSet;
delete h5PPFile;
Expand Down
Loading

0 comments on commit 8612a09

Please sign in to comment.