@@ -44,10 +44,7 @@ export async function createInstantiator(options, swift) {
4444 i32Stack . push ( id ) ;
4545 i32Stack . push ( ( value . value | 0 ) ) ;
4646 i32Stack . push ( value . enabled ? 1 : 0 ) ;
47- const cleanup = ( ) => {
48- swift . memory . release ( id ) ;
49- } ;
50- return { cleanup } ;
47+ return { cleanup : undefined } ;
5148 } ,
5249 lift : ( ) => {
5350 const bool = i32Stack . pop ( ) !== 0 ;
@@ -96,6 +93,7 @@ export async function createInstantiator(options, swift) {
9693 }
9794 bjs [ "swift_js_init_memory" ] = function ( sourceId , bytesPtr ) {
9895 const source = swift . memory . getObject ( sourceId ) ;
96+ swift . memory . release ( sourceId ) ;
9997 const bytes = new Uint8Array ( memory . buffer , bytesPtr ) ;
10098 bytes . set ( source ) ;
10199 }
@@ -325,7 +323,6 @@ export async function createInstantiator(options, swift) {
325323 const nameBytes = textEncoder . encode ( name ) ;
326324 const nameId = swift . memory . retain ( nameBytes ) ;
327325 const ret = instance . exports . bjs_DefaultGreeter_init ( nameId , nameBytes . length ) ;
328- swift . memory . release ( nameId ) ;
329326 return DefaultGreeter . __construct ( ret ) ;
330327 }
331328 get name ( ) {
@@ -338,7 +335,6 @@ export async function createInstantiator(options, swift) {
338335 const valueBytes = textEncoder . encode ( value ) ;
339336 const valueId = swift . memory . retain ( valueBytes ) ;
340337 instance . exports . bjs_DefaultGreeter_name_set ( this . pointer , valueId , valueBytes . length ) ;
341- swift . memory . release ( valueId ) ;
342338 }
343339 }
344340 class EmptyGreeter extends SwiftHeapObject {
@@ -366,10 +362,6 @@ export async function createInstantiator(options, swift) {
366362 tagId = swift . memory . retain ( tagBytes ) ;
367363 }
368364 const ret = instance . exports . bjs_ConstructorDefaults_init ( nameId , nameBytes . length , count , enabled , status , + isSome , isSome ? tagId : 0 , isSome ? tagBytes . length : 0 ) ;
369- swift . memory . release ( nameId ) ;
370- if ( tagId != undefined ) {
371- swift . memory . release ( tagId ) ;
372- }
373365 return ConstructorDefaults . __construct ( ret ) ;
374366 }
375367 get name ( ) {
@@ -382,7 +374,6 @@ export async function createInstantiator(options, swift) {
382374 const valueBytes = textEncoder . encode ( value ) ;
383375 const valueId = swift . memory . retain ( valueBytes ) ;
384376 instance . exports . bjs_ConstructorDefaults_name_set ( this . pointer , valueId , valueBytes . length ) ;
385- swift . memory . release ( valueId ) ;
386377 }
387378 get count ( ) {
388379 const ret = instance . exports . bjs_ConstructorDefaults_count_get ( this . pointer ) ;
@@ -419,9 +410,6 @@ export async function createInstantiator(options, swift) {
419410 valueId = swift . memory . retain ( valueBytes ) ;
420411 }
421412 instance . exports . bjs_ConstructorDefaults_tag_set ( this . pointer , + isSome , isSome ? valueId : 0 , isSome ? valueBytes . length : 0 ) ;
422- if ( valueId != undefined ) {
423- swift . memory . release ( valueId ) ;
424- }
425413 }
426414 }
427415 const ConfigHelpers = __bjs_createConfigHelpers ( ) ( ) ;
@@ -440,7 +428,6 @@ export async function createInstantiator(options, swift) {
440428 instance . exports . bjs_testStringDefault ( messageId , messageBytes . length ) ;
441429 const ret = tmpRetString ;
442430 tmpRetString = undefined ;
443- swift . memory . release ( messageId ) ;
444431 return ret ;
445432 } ,
446433 testNegativeIntDefault : function bjs_testNegativeIntDefault ( value = - 42 ) {
@@ -469,9 +456,6 @@ export async function createInstantiator(options, swift) {
469456 instance . exports . bjs_testOptionalDefault ( + isSome , isSome ? nameId : 0 , isSome ? nameBytes . length : 0 ) ;
470457 const optResult = tmpRetString ;
471458 tmpRetString = undefined ;
472- if ( nameId != undefined ) {
473- swift . memory . release ( nameId ) ;
474- }
475459 return optResult ;
476460 } ,
477461 testOptionalStringDefault : function bjs_testOptionalStringDefault ( greeting = "Hi" ) {
@@ -484,9 +468,6 @@ export async function createInstantiator(options, swift) {
484468 instance . exports . bjs_testOptionalStringDefault ( + isSome , isSome ? greetingId : 0 , isSome ? greetingBytes . length : 0 ) ;
485469 const optResult = tmpRetString ;
486470 tmpRetString = undefined ;
487- if ( greetingId != undefined ) {
488- swift . memory . release ( greetingId ) ;
489- }
490471 return optResult ;
491472 } ,
492473 testMultipleDefaults : function bjs_testMultipleDefaults ( title = "Default Title" , count = 10 , enabled = false ) {
@@ -495,7 +476,6 @@ export async function createInstantiator(options, swift) {
495476 instance . exports . bjs_testMultipleDefaults ( titleId , titleBytes . length , count , enabled ) ;
496477 const ret = tmpRetString ;
497478 tmpRetString = undefined ;
498- swift . memory . release ( titleId ) ;
499479 return ret ;
500480 } ,
501481 testEnumDefault : function bjs_testEnumDefault ( status = StatusValues . Active ) {
@@ -572,9 +552,6 @@ export async function createInstantiator(options, swift) {
572552 const id = swift . memory . retain ( bytes ) ;
573553 i32Stack . push ( bytes . length ) ;
574554 i32Stack . push ( id ) ;
575- arrayCleanups . push ( ( ) => {
576- swift . memory . release ( id ) ;
577- } ) ;
578555 }
579556 i32Stack . push ( names . length ) ;
580557 instance . exports . bjs_testStringArrayDefault ( ) ;
@@ -650,7 +627,6 @@ export async function createInstantiator(options, swift) {
650627 instance . exports . bjs_testMixedWithArrayDefault ( nameId , nameBytes . length , enabled ) ;
651628 const ret = tmpRetString ;
652629 tmpRetString = undefined ;
653- swift . memory . release ( nameId ) ;
654630 for ( const cleanup of arrayCleanups ) { cleanup ( ) ; }
655631 return ret ;
656632 } ,
0 commit comments