Skip to content

Commit

Permalink
Solved leaky pointers and variable scope problems (Thanks to Ulf Lorenz)
Browse files Browse the repository at this point in the history
  • Loading branch information
juanjosegarciaripoll committed Dec 7, 2017
1 parent e963190 commit 93bb36b
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/linalg/find_blocks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ namespace linalg {
if (nblocks == 1) {
block_rows = 0;
block_cols = 0;
delete[] row_block;
delete[] col_block;
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/rand/rand64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ void init_by_array(uint64_t init_key[], int key_length)
/* generates a random number on [0, 2^64-1]-interval */
uint64_t genrand_int64(void)
{
int i;
uint64_t x;
static uint64_t mag01[2]={0ULL, MATRIX_A};

Expand All @@ -119,6 +118,7 @@ uint64_t genrand_int64(void)
if (mti == NN+1)
init_genrand(5489ULL);

int i;
for (i=0;i<NN-MM;i++) {
x = (mt[i]&UM)|(mt[i+1]&LM);
mt[i] = mt[i+MM] ^ (x>>1) ^ mag01[(int)(x&1ULL)];
Expand Down
3 changes: 1 addition & 2 deletions src/sdf/data_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,9 @@ static int get_lock(char const *lockName, bool wait)
#if defined(_MSC_VER) || defined(__MINGW32__)
return 1;
#else
int fd;
do {
mode_t m = umask(0);
fd = open(lockName, O_RDWR|O_CREAT, 0666);
int fd = open(lockName, O_RDWR|O_CREAT, 0666);
umask(m);
if( fd >= 0 && flock( fd, LOCK_EX | LOCK_NB ) < 0 )
{
Expand Down
2 changes: 1 addition & 1 deletion src/sdf/idata_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ InDataFile::read_variable_name()
char *buffer = new char[var_name_size];
read_raw(buffer, var_name_size);
std::string output(buffer);
delete buffer;
delete[] buffer;
return output;
}

Expand Down
2 changes: 1 addition & 1 deletion src/sdf/odata_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ OutDataFile::write_variable_name(const std::string &name)
memset(buffer, 0, var_name_size);
strncpy(buffer, name.c_str(), std::min<size_t>(var_name_size - 1, name.size()));
write_raw(buffer, var_name_size);
delete buffer;
delete[] buffer;
}

void
Expand Down
3 changes: 0 additions & 3 deletions src/tools/jobs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ Job::parse_file(std::istream &s, var_list &data)
Job::Job(int argc, const char **argv) :
filename_("no file")
{
bool loaded = false;
bool print_jobs = false;
bool first_job_found = false;
bool last_job_found = false;
Expand All @@ -127,7 +126,6 @@ Job::Job(int argc, const char **argv) :
<< std::endl;
abort();
}
loaded = true;
} else if (!strcmp(argv[i], "--print-jobs")) {
print_jobs = true;
} else if (!strcmp(argv[i], "--this-job")) {
Expand Down Expand Up @@ -178,7 +176,6 @@ Job::Job(int argc, const char **argv) :
abort();
}
variables_.push_back(v);
loaded = true;
} else if (!strcmp(argv[i], "--help")) {
std::cout << "Arguments:\n"
"--help\n"
Expand Down

0 comments on commit 93bb36b

Please sign in to comment.