Skip to content

Commit 1c91dcf

Browse files
committed
fbc-tests: fix obvious memory leaks
- fix some of the memory leaks that are due to the tests themselves - other remaining memory leaks are bugs in the code generation
1 parent 4a2316b commit 1c91dcf

File tree

7 files changed

+26
-1
lines changed

7 files changed

+26
-1
lines changed

tests/gfx/image-expr.bas

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,9 @@ SUITE( fbc_tests.gfx.image_expr )
715715
'' px->p
716716
line px->p, (0, 0) - (SCREEN_W-1, SCREEN_H-1), rgb(0,0,255), bf
717717
CU_ASSERT( hImageIsFilledWithColor( x.p, rgb(0,0,255) ) )
718+
719+
'' free x.p otherwise considered a memory leak
720+
imagedestroy( x.p )
718721
end sub
719722

720723
private sub hTestConstSource( )

tests/pointers/casting1.bas

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ SUITE( fbc_tests.pointers.casting1 )
4949
dim as ulong ul = culng( pclass )
5050
#endif
5151
dim as uinteger ui = cuint( pclass )
52+
53+
'' free t.fparray otherwise is considered a memory leak
54+
deallocate t.fparray
5255
END_TEST
5356

5457
END_SUITE

tests/pointers/casting3.bas

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ SUITE( fbc_tests.pointers.casting3 )
2121

2222
CU_ASSERT_EQUAL( bar->l, (TEST_VAL and not 255) )
2323

24+
'' free bar otherwise is considered memory leak
25+
deallocate bar
26+
2427
END_TEST
2528

2629
END_SUITE

tests/pointers/new-delete.bas

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,8 @@ SUITE( fbc_tests.pointers.new_delete )
888888

889889
function f( byval p as ClassUDT ptr ) as UDT
890890
function = type( p->i )
891+
'' free p otherwise it is a memory leak
892+
delete p
891893
end function
892894

893895
TEST( default )

tests/structs/derived-ptr-assign.bas

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ SUITE( fbc_tests.structs.derived_ptr_assign )
3434

3535
b = d '' ok
3636
CU_ASSERT( b.value = 5678 )
37+
38+
'' delete pd otherwise considered a memory leak
39+
delete pd
3740
END_TEST
3841

3942
'' -------------------------------------------------------------------------
@@ -69,6 +72,9 @@ SUITE( fbc_tests.structs.derived_ptr_assign )
6972

7073
b = d '' ok
7174
CU_ASSERT( b.value = 5678 )
75+
76+
'' delete pd otherwise considered a memory leak
77+
delete pd
7278
END_TEST
7379

7480
END_SUITE

tests/structs/obj_property_idx2.bas

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ SUITE( fbc_tests.structs.obj_property_idx2 )
4444
f3->bar("foo")->bar("bar")->bar = "hi"
4545

4646
CU_ASSERT_EQUAL( f3->bar("foo")->bar("bar")->bar, "hi" )
47-
47+
48+
'' clean-up otherwise considered a memory leak
49+
delete f3
50+
delete f2
51+
delete f
4852
END_TEST
4953

5054
END_SUITE

tests/virtual/virtual.bas

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,13 @@ SUITE( fbc_tests.virtual_.virtual_ )
283283
CU_ASSERT( pa->f( ) = &hA1 )
284284
CU_ASSERT( pa->f( 1 ) = &hA2 )
285285
CU_ASSERT( pa->f( clngint( 1 ) ) = &hA3 )
286+
delete pa
286287

287288
pa = new B
288289
CU_ASSERT( pa->f( ) = &hB1 )
289290
CU_ASSERT( pa->f( 1 ) = &hB2 )
290291
CU_ASSERT( pa->f( clngint( 1 ) ) = &hB3 )
292+
delete pa
291293
END_TEST
292294
END_TEST_GROUP
293295

@@ -324,6 +326,7 @@ SUITE( fbc_tests.virtual_.virtual_ )
324326
CU_ASSERT( Asets = 1 )
325327
CU_ASSERT( Bgets = 0 )
326328
CU_ASSERT( Bsets = 0 )
329+
delete pa
327330

328331
Agets = 0
329332
Asets = 0
@@ -336,6 +339,7 @@ SUITE( fbc_tests.virtual_.virtual_ )
336339
CU_ASSERT( Asets = 0 )
337340
CU_ASSERT( Bgets = 1 )
338341
CU_ASSERT( Bsets = 1 )
342+
delete pa
339343
END_TEST
340344
END_TEST_GROUP
341345

0 commit comments

Comments
 (0)