Are the _d_arrayappend functions, thread-safe?
Jeff Davey
jeffd at gwava.com
Tue Jun 19 11:20:13 PDT 2007
Ack, I pasted the wrong function (that one was a result of some debugging).
Here's the right one:
char[][] split(char[] data)
{
char[][] rtn;
int lastPos = 0;
int index = 0;
int numSpaces = std.string.count(data, " ");
rtn = new char[][numSpaces + 1];
if (numSpaces > 0)
{
for (int i = 0; i < data.length; i++)
{
if (data[i] == ' ')
{
rtn[index++] = data[lastPos .. i];
lastPos = i + 1;
}
}
}
rtn[index] = data[lastPos .. data.length];
return rtn;
}
There might still be some issues with something else local, but I'm finding it very strange that replacing std.string.split with that function, I'm no longer segfaulting.
More information about the Digitalmars-d
mailing list