@@ -324,15 +324,16 @@ public void toNative(@Cached() ToNativeNode toNative) {
324324 toNative .execute (this );
325325 }
326326
327- public long setExternalDataAddress (long address ) {
327+ public void setExternalDataAddress (long address ) {
328328 this .dataAddress = NativeMemory .wrapExternalNativeMemory (address , delegate );
329329 if (dataAddressToNativeMirrors != null ) {
330330 addToAddressDebugMapping (address );
331331 }
332- return address ;
333332 }
334333
335334 long setDataAddress (long address ) {
335+ // use setExternalDataAddress for empty data address
336+ assert address != getEmptyDataAddress ();
336337 this .dataAddress = NativeMemory .wrapNativeMemory (address , delegate );
337338 if (dataAddressToNativeMirrors != null ) {
338339 addToAddressDebugMapping (address );
@@ -378,7 +379,7 @@ void allocateNativeString(byte[] bytes) {
378379 @ TruffleBoundary
379380 void allocateNative (CharSXPWrapper [] wrappers ) {
380381 if (wrappers .length == 0 ) {
381- setDataAddress (getEmptyDataAddress ());
382+ setExternalDataAddress (getEmptyDataAddress ());
382383 } else {
383384 long addr = setDataAddress (NativeMemory .allocate (wrappers .length * (long ) Long .BYTES , "CharSXPWrapper" ));
384385 for (int i = 0 ; i < wrappers .length ; i ++) {
@@ -390,7 +391,7 @@ void allocateNative(CharSXPWrapper[] wrappers) {
390391 @ TruffleBoundary
391392 void allocateNative (Object [] elements ) {
392393 if (elements .length == 0 ) {
393- setDataAddress (getEmptyDataAddress ());
394+ setExternalDataAddress (getEmptyDataAddress ());
394395 } else {
395396 long addr = setDataAddress (NativeMemory .allocate (elements .length * (long ) Long .BYTES , "SEXP array" ));
396397 for (int i = 0 ; i < elements .length ; i ++) {
0 commit comments