mirror of
https://github.com/corda/corda.git
synced 2025-02-01 16:58:27 +00:00
replace use of strndup with custom function
Windows doesn't have strndup, nor can I find an equivalent, so I wrote my own trivial implementation.
This commit is contained in:
parent
26209efac2
commit
30516ab94a
@ -1816,6 +1816,15 @@ void ArgParser::printUsage(const char* exe) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char*
|
||||||
|
myStrndup(const char* src, unsigned length)
|
||||||
|
{
|
||||||
|
char* s = static_cast<char*>(malloc(length + 1));
|
||||||
|
memcpy(s, src, length);
|
||||||
|
s[length] = 0;
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
class Arguments {
|
class Arguments {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -1843,7 +1852,7 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
destA = strndup(src, split - src);
|
destA = myStrndup(src, split - src);
|
||||||
destB = strdup(split + 1);
|
destB = strdup(split + 1);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -1879,9 +1888,9 @@ public:
|
|||||||
|
|
||||||
if(entry.value) {
|
if(entry.value) {
|
||||||
if(const char* entryClassEnd = strchr(entry.value, '.')) {
|
if(const char* entryClassEnd = strchr(entry.value, '.')) {
|
||||||
entryClass = strndup(entry.value, entryClassEnd - entry.value);
|
entryClass = myStrndup(entry.value, entryClassEnd - entry.value);
|
||||||
if(const char* entryMethodEnd = strchr(entryClassEnd, '(')) {
|
if(const char* entryMethodEnd = strchr(entryClassEnd, '(')) {
|
||||||
entryMethod = strndup(entryClassEnd + 1, entryMethodEnd - entryClassEnd - 1);
|
entryMethod = myStrndup(entryClassEnd + 1, entryMethodEnd - entryClassEnd - 1);
|
||||||
entrySpec = strdup(entryMethodEnd);
|
entrySpec = strdup(entryMethodEnd);
|
||||||
} else {
|
} else {
|
||||||
entryMethod = strdup(entryClassEnd + 1);
|
entryMethod = strdup(entryClassEnd + 1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user