GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_delete.c Lines: 15 15 100.0 %
Date: 2026-03-06 19:21:09 Branches: 8 8 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
/**   Display Management (Display)                                        */
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_display.h"
30
31
32
/**************************************************************************/
33
/*                                                                        */
34
/*  FUNCTION                                               RELEASE        */
35
/*                                                                        */
36
/*    _gx_display_delete                                  PORTABLE C      */
37
/*                                                           6.1          */
38
/*  AUTHOR                                                                */
39
/*                                                                        */
40
/*    Kenneth Maxwell, Microsoft Corporation                              */
41
/*                                                                        */
42
/*  DESCRIPTION                                                           */
43
/*                                                                        */
44
/*    This function deletes a previous-created display                    */
45
/*                                                                        */
46
/*  INPUT                                                                 */
47
/*                                                                        */
48
/*    display                               Display control block         */
49
/*    display_driver_cleanup                Display driver cleanup routine*/
50
/*                                                                        */
51
/*  OUTPUT                                                                */
52
/*                                                                        */
53
/*    status                                Completion status             */
54
/*                                                                        */
55
/*  CALLS                                                                 */
56
/*                                                                        */
57
/*    [display_driver_cleanup]              Call the user-supplied        */
58
/*                                            display driver cleanup      */
59
/*                                            routine                     */
60
/*    memset                                Cleanup the memory            */
61
/*                                                                        */
62
/*  CALLED BY                                                             */
63
/*                                                                        */
64
/*    Application Code                                                    */
65
/*                                                                        */
66
/**************************************************************************/
67
9
UINT  _gx_display_delete(GX_DISPLAY *display, VOID (*display_driver_cleanup)(GX_DISPLAY *))
68
{
69
GX_DISPLAY *previous_display;
70
71
9
    if (_gx_system_display_created_count > 0)
72
    {
73
8
        display_driver_cleanup(display);
74
8
        _gx_system_display_created_count--;
75
76
8
        if (display -> gx_display_created_previous)
77
        {
78
            /* this is not first display, unlink it: */
79
80
2
            previous_display = display -> gx_display_created_previous;
81
2
            previous_display -> gx_display_created_next = display -> gx_display_created_next;
82
83
2
            if (display -> gx_display_created_next)
84
            {
85
1
                display -> gx_display_created_next -> gx_display_created_previous = previous_display;
86
            }
87
        }
88
        else
89
        {
90
            /* this is the first display, unlink it */
91
6
            _gx_system_display_created_list = display -> gx_display_created_next;
92
93
6
            if (_gx_system_display_created_list)
94
            {
95
1
                _gx_system_display_created_list -> gx_display_created_previous = GX_NULL;
96
            }
97
        }
98
8
        memset(display, 0, sizeof(GX_DISPLAY));
99
100
        /* Return successful status.  */
101
8
        return(GX_SUCCESS);
102
    }
103
1
    return GX_FAILURE;
104
}
105