GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_canvas_delete.c Lines: 14 14 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
/**   Canvas Management (Canvas)                                          */
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
#include "gx_canvas.h"
31
32
33
/**************************************************************************/
34
/*                                                                        */
35
/*  FUNCTION                                               RELEASE        */
36
/*                                                                        */
37
/*    _gx_canvas_delete                                   PORTABLE C      */
38
/*                                                           6.1          */
39
/*  AUTHOR                                                                */
40
/*                                                                        */
41
/*    Kenneth Maxwell, Microsoft Corporation                              */
42
/*                                                                        */
43
/*  DESCRIPTION                                                           */
44
/*                                                                        */
45
/*    This function deletes a canvas.                                     */
46
/*                                                                        */
47
/*  INPUT                                                                 */
48
/*                                                                        */
49
/*    canvas                                Canvas control block          */
50
/*                                                                        */
51
/*  OUTPUT                                                                */
52
/*                                                                        */
53
/*    status                                Completion status             */
54
/*                                                                        */
55
/*  CALLS                                                                 */
56
/*                                                                        */
57
/*    memset                                Set control block and canvas  */
58
/*                                            memory to zero              */
59
/*                                                                        */
60
/*  CALLED BY                                                             */
61
/*                                                                        */
62
/*    Application Code                                                    */
63
/*                                                                        */
64
/**************************************************************************/
65
287
UINT  _gx_canvas_delete(GX_CANVAS *canvas)
66
{
67
    /* lock access to gx_system */
68
69
287
    GX_ENTER_CRITICAL
70
71
287
    if (_gx_system_canvas_created_count > 0)
72
    {
73
286
        if (canvas -> gx_canvas_created_previous)
74
        {
75
3
            canvas -> gx_canvas_created_previous -> gx_canvas_created_next = canvas -> gx_canvas_created_next;
76
3
            if (canvas -> gx_canvas_created_next)
77
            {
78
2
                canvas -> gx_canvas_created_next -> gx_canvas_created_previous = canvas -> gx_canvas_created_previous;
79
            }
80
        }
81
        else
82
        {
83
283
            _gx_system_canvas_created_list = canvas -> gx_canvas_created_next;
84
85
283
            if (_gx_system_canvas_created_list)
86
            {
87
282
                _gx_system_canvas_created_list -> gx_canvas_created_previous = GX_NULL;
88
            }
89
        }
90
91
286
        _gx_system_canvas_created_count--;
92
93
        /* Only for Win32, we sometimes have to create module 4 aligned scratch memory buffer */
94
        #ifdef GX_TARGET_WIN32
95
        if (canvas -> gx_canvas_padded_memory != GX_NULL)
96
        {
97
            free(canvas -> gx_canvas_padded_memory);
98
        }
99
        #endif
100
101
        /* Clear the screen control block.  */
102
286
        memset(canvas, 0, sizeof(GX_CANVAS));
103
    }
104
    /* unlock gx_system.  */
105
287
    GX_EXIT_CRITICAL
106
107
    /* Return successful status.  */
108
287
    return(GX_SUCCESS);
109
}
110