Skip to content

Commit

Permalink
Feature #2673 wchar argv (#2999)
Browse files Browse the repository at this point in the history
* Per #2673, switch to STL vector to attempt to squash a SonarQube bug.

* Per #2673, remove m_strlen() entirely.

* Per #2673, try again ci-skip-unit

* Per #2673, switching to 2 more vectors
  • Loading branch information
JohnHalleyGotway authored Oct 17, 2024
1 parent 83bf380 commit 4f99723
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions src/libcode/vx_python3_utils/wchar_argv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,36 +146,29 @@ for (int j=0; j<(a.n()); ++j) {

int N = len + a.n();

char * s = new char [N];

char ** av = new char * [a.n()];

memset(s, 0, N);
vector<char> s(N, 0);
vector<char *> av(a.n(), nullptr);

for (int j=0; j<(a.n()); ++j) {

av[j] = s + k;

c = a[j].c_str();

len = c.length();

m_strncpy(s + k, c.text(), len, method_name);
m_strncpy(s.data() + k, c.text(), len, method_name);

av[j] = s.data() + k;

k += (len + 1);

}

set(a.n(), av);
set(a.n(), av.data());

//
// done
//

if ( s ) { delete [] s; s = nullptr; }

if ( av ) { delete [] av; av = nullptr; }

return;

}
Expand All @@ -191,8 +184,6 @@ void Wchar_Argv::set(int _argc, char ** _argv)
clear();

int k;
int *len = new int [_argc];


Argc = _argc;

Expand All @@ -201,13 +192,14 @@ Argc = _argc;
//

int argv_len = 0;
vector<int> len(_argc, 0);

for (int j=0; j<_argc; ++j) {

// we're using the len array here because
// we don't want to call m_strlen more than
// once on each argv value
len[j] = (_argv == nullptr) ? 0 : len[j] = m_strlen(_argv[j]);
if (_argv) len[j] = m_strlen(_argv[j]);

argv_len += len[j];

Expand Down Expand Up @@ -276,8 +268,6 @@ for (int j=0; j<Argc; ++j) {
// done
//

if ( len ) { delete [] len; len = nullptr; }

return;

}
Expand Down

0 comments on commit 4f99723

Please sign in to comment.