• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nasa / trick / 20248135608

15 Dec 2025 09:31PM UTC coverage: 55.934% (+0.003%) from 55.931%
20248135608

push

github

web-flow
Freed REF2 reference attr before freeing REF2 instance. (#1889)

* Freed REF2 reference attr before freeing REF2 instance.

* Added freeing units and ref_attr to ref_free function and utilized the function for free allocated memory within the REF2 structure.

* Added needed lib for applicable unittest.

* Added needed lib to the applicable unittest.

* Added needed lib to the applicable unittest.

* Added needed lib for applicable unittest.

* Updated not to list libs multiple times for macOS and use --start-group and --end-group for linux to avoid duplicate lib listing.

* Updated test makefile to be consistent.

7 of 9 new or added lines in 3 files covered. (77.78%)

2 existing lines in 1 file now uncovered.

12476 of 22305 relevant lines covered (55.93%)

300385.83 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.0
/trick_source/sim_services/MemoryManager/ref_free.cpp
1
/*
2
   PURPOSE: (Frees allocated memory within a REF2 structure. Does not free the REF2 itself)
3
   PROGRAMMERS: (((Alex Lin) (NASA) (5/13)))
4
*/
5

6
#include <stdlib.h>
7

8
#include "trick/reference.h"
9
#include "trick/dllist.h"
10

11
extern "C" void ref_free(REF2 * ref) {
637✔
12
    if ( ref ) {
637✔
13
        if ( ref->address_path ) {
631✔
14
            DLLPOS pos = DLL_GetHeadPosition(ref->address_path);
553✔
15
            DLLPOS prev = NULL;
553✔
16
            while (pos != NULL) {
1,106✔
17
                prev = pos;
553✔
18
                // The address nodes were allocated with "new"
19
                delete (ADDRESS_NODE *)DLL_GetNext(&pos, ref->address_path);
553✔
20
                DLL_RemoveAt(prev, ref->address_path);
553✔
21
            }
22
            DLL_Delete(ref->address_path) ;
553✔
23
        }
24

25
        // The reference string was allocated with strdup.
26
        if ( ref->reference ) {
631✔
27
            free(ref->reference) ;
631✔
28
            ref->reference = NULL;
631✔
29
        }
30

31
        // Free units string
32
        if (ref->units) {
631✔
33
            free(ref->units);
1✔
34
            ref->units = NULL;
1✔
35
        }
36

37
        // Free ref_attr, however, not freeing the shared attr
38
        if (ref->ref_attr) {
631✔
NEW
39
            free(ref->ref_attr);
×
NEW
40
            ref->ref_attr = NULL;
×
41
        }
42
    }
43
    return ;
637✔
44
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc