| 176 | |
| 177 | #ifndef WIN32 |
| 178 | void StringStrdup( |
| 179 | struct ParseState* Parser, struct Value* ReturnValue, struct Value** Param, int NumArgs) |
| 180 | { |
| 181 | /* Through the script heap, not the C library's strdup: a script's free() |
| 182 | is ScriptHeap::release, which ignores a pointer the heap does not own, so |
| 183 | a libc strdup would leak for the whole run and log a warning per free. |
| 184 | Anything a script can free has to be allocated the way its malloc is. */ |
| 185 | const char* src = Param[0]->Val->Pointer; |
| 186 | if (src == NULL) |
| 187 | { |
| 188 | ReturnValue->Val->Pointer = NULL; |
| 189 | return; |
| 190 | } |
| 191 | |
| 192 | size_t size = strlen(src) + 1; |
| 193 | void* copy = ckpt_script_malloc(size); |
| 194 | if (copy != NULL) |
| 195 | { |
| 196 | memcpy(copy, src, size); |
| 197 | } |
| 198 | ReturnValue->Val->Pointer = copy; |
| 199 | } |
| 200 | |
| 201 | void StringStrtok_r( |
| 202 | struct ParseState* Parser, struct Value* ReturnValue, struct Value** Param, int NumArgs) |
nothing calls this directly
no test coverage detected