(jstr, returnWithLength, allocator, funcName)
| 8407 | }; |
| 8408 | |
| 8409 | const __allocCStr = function(jstr, returnWithLength, allocator, funcName){ |
| 8410 | __affirmAlloc(target, funcName); |
| 8411 | if('string'!==typeof jstr) return null; |
| 8412 | const u = cache.utf8Encoder.encode(jstr), |
| 8413 | ptr = allocator(u.length+1); |
| 8414 | let toFree = ptr; |
| 8415 | try{ |
| 8416 | const heap = heapWrappers().HEAP8U; |
| 8417 | heap.set(u, Number(ptr)); |
| 8418 | heap[__ptrAdd(ptr, u.length)] = 0; |
| 8419 | toFree = __NullPtr; |
| 8420 | return returnWithLength ? [ptr, u.length] : ptr; |
| 8421 | }finally{ |
| 8422 | if( toFree ) target.dealloc(toFree); |
| 8423 | } |
| 8424 | }; |
| 8425 | |
| 8426 | /** |
| 8427 | Uses target.alloc() to allocate enough memory for jstrlen(jstr)+1 |
no test coverage detected