Skip to content

Commit

Permalink
Per #2673, switching to 2 more vectors
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnHalleyGotway committed Oct 17, 2024
1 parent 52a6129 commit 342358d
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 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 Down Expand Up @@ -206,7 +199,7 @@ 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
if (_argv && _argv[j]) len[j] = m_strlen(_argv[j]);
if (_argv) len[j] = m_strlen(_argv[j]);

argv_len += len[j];

Expand Down

0 comments on commit 342358d

Please sign in to comment.