GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_system_all_views_free.c Lines: 22 22 100.0 %
Date: 2026-03-06 19:21:09 Branches: 12 12 100.0 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 * Copyright (c) 2026-present Eclipse ThreadX contributors
4
 *
5
 * This program and the accompanying materials are made available under the
6
 * terms of the MIT License which is available at
7
 * https://opensource.org/licenses/MIT.
8
 *
9
 * SPDX-License-Identifier: MIT
10
 **************************************************************************/
11
12
13
/**************************************************************************/
14
/**************************************************************************/
15
/**                                                                       */
16
/** GUIX Component                                                        */
17
/**                                                                       */
18
/**   System Management (System)                                          */
19
/**                                                                       */
20
/**************************************************************************/
21
22
#define GX_SOURCE_CODE
23
24
25
/* Include necessary system files.  */
26
27
#include "gx_api.h"
28
#include "gx_system.h"
29
#include "gx_utility.h"
30
31
32
/**************************************************************************/
33
/*                                                                        */
34
/*  FUNCTION                                               RELEASE        */
35
/*                                                                        */
36
/*    _gx_system_all_views_free                           PORTABLE C      */
37
/*                                                           6.1          */
38
/*  AUTHOR                                                                */
39
/*                                                                        */
40
/*    Kenneth Maxwell, Microsoft Corporation                              */
41
/*                                                                        */
42
/*  DESCRIPTION                                                           */
43
/*                                                                        */
44
/*    This function releaes the views attached to the given root window   */
45
/*    and it's chilren back to the free list.                             */
46
/*                                                                        */
47
/*  INPUT                                                                 */
48
/*                                                                        */
49
/*    root                                  Root window that needs to     */
50
/*                                            have it's views released    */
51
/*                                                                        */
52
/*  OUTPUT                                                                */
53
/*                                                                        */
54
/*    views owned by this root and children are returned to free list     */
55
/*                                                                        */
56
/*  CALLS                                                                 */
57
/*                                                                        */
58
/*     _gx_system_views_free                Free views for one window     */
59
/*     _gx_system_error_process             Process error code            */
60
/*                                                                        */
61
/*  CALLED BY                                                             */
62
/*                                                                        */
63
/*    GUIX Internal Code                                                  */
64
/*                                                                        */
65
/**************************************************************************/
66
1885
VOID _gx_system_all_views_free(GX_WINDOW_ROOT *root)
67
{
68
#ifndef GX_DISABLE_ERROR_CHECKING
69
int viewcount;
70
#endif
71
72
GX_VIEW   *test;
73
GX_WIDGET *child;
74
GX_WINDOW *win;
75
76
    /* pick up pointer to first child window */
77
1885
    child = root -> gx_widget_first_child;
78
79
    /* free each of the top-level window's views */
80
6445
    while (child)
81
    {
82
4560
        if (child -> gx_widget_type >= GX_TYPE_WINDOW)
83
        {
84
4509
            win = (GX_WINDOW *)child;
85
4509
            test = win -> gx_window_views;
86
87
            /* does this window have any views? */
88
89
4509
            if (test)
90
            {
91
447
                _gx_system_views_free(test);
92
447
                win -> gx_window_views = GX_NULL;
93
            }
94
        }
95
4560
        child = (child -> gx_widget_next);
96
    }
97
98
99
    /* lastly, free the root window's views */
100
101
1885
    test = root -> gx_window_views;
102
103
1885
    if (test)
104
    {
105
785
        _gx_system_views_free(test);
106
785
        root -> gx_window_views = GX_NULL;
107
    }
108
109
#ifndef GX_DISABLE_ERROR_CHECKING
110
1885
    test = _gx_system_free_views;
111
112
1885
    viewcount = 0;
113
114
61553
    while (test)
115
    {
116
59668
        viewcount++;
117
59668
        test = test -> gx_view_next;
118
    }
119
120
1885
    if (viewcount != GX_MAX_VIEWS)
121
    {
122
293
        _gx_system_error_process(GX_SYSTEM_OUT_OF_VIEWS);
123
    }
124
#endif
125
1885
}
126