Skip to content

Commit 4b3a359

Browse files
committed
Add comment to copyToCString about memory allocation
1 parent 4cfef36 commit 4b3a359

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

wrapper.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ function setupMethods (soljson) {
3030

3131
var copyToCString = function (str, ptr) {
3232
var length = soljson.lengthBytesUTF8(str);
33+
// This is allocating memory using solc's allocator.
34+
// Assuming copyToCString is only used in the context of wrapCallback, solc will free these pointers.
35+
// See https://github.com/ethereum/solidity/blob/v0.5.13/libsolc/libsolc.h#L37-L40
3336
var buffer = soljson._malloc(length + 1);
3437
soljson.stringToUTF8(str, buffer, length + 1);
3538
soljson.setValue(ptr, buffer, '*');

0 commit comments

Comments
 (0)