GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_canvas_delete.c Lines: 14 14 100.0 %
Date: 2024-12-05 08:52:37 Branches: 8 8 100.0 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 *
4
 * This program and the accompanying materials are made available under the
5
 * terms of the MIT License which is available at
6
 * https://opensource.org/licenses/MIT.
7
 *
8
 * SPDX-License-Identifier: MIT
9
 **************************************************************************/
10
11
12
/**************************************************************************/
13
/**************************************************************************/
14
/**                                                                       */
15
/** GUIX Component                                                        */
16
/**                                                                       */
17
/**   Canvas Management (Canvas)                                          */
18
/**                                                                       */
19
/**************************************************************************/
20
21
#define GX_SOURCE_CODE
22
23
24
/* Include necessary system files.  */
25
26
#include "gx_api.h"
27
#include "gx_system.h"
28
#include "gx_utility.h"
29
#include "gx_canvas.h"
30
31
32
/**************************************************************************/
33
/*                                                                        */
34
/*  FUNCTION                                               RELEASE        */
35
/*                                                                        */
36
/*    _gx_canvas_delete                                   PORTABLE C      */
37
/*                                                           6.1          */
38
/*  AUTHOR                                                                */
39
/*                                                                        */
40
/*    Kenneth Maxwell, Microsoft Corporation                              */
41
/*                                                                        */
42
/*  DESCRIPTION                                                           */
43
/*                                                                        */
44
/*    This function deletes a canvas.                                     */
45
/*                                                                        */
46
/*  INPUT                                                                 */
47
/*                                                                        */
48
/*    canvas                                Canvas control block          */
49
/*                                                                        */
50
/*  OUTPUT                                                                */
51
/*                                                                        */
52
/*    status                                Completion status             */
53
/*                                                                        */
54
/*  CALLS                                                                 */
55
/*                                                                        */
56
/*    memset                                Set control block and canvas  */
57
/*                                            memory to zero              */
58
/*                                                                        */
59
/*  CALLED BY                                                             */
60
/*                                                                        */
61
/*    Application Code                                                    */
62
/*                                                                        */
63
/*  RELEASE HISTORY                                                       */
64
/*                                                                        */
65
/*    DATE              NAME                      DESCRIPTION             */
66
/*                                                                        */
67
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
68
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
69
/*                                            resulting in version 6.1    */
70
/*                                                                        */
71
/**************************************************************************/
72
287
UINT  _gx_canvas_delete(GX_CANVAS *canvas)
73
{
74
    /* lock access to gx_system */
75
76
287
    GX_ENTER_CRITICAL
77
78
287
    if (_gx_system_canvas_created_count > 0)
79
    {
80
286
        if (canvas -> gx_canvas_created_previous)
81
        {
82
3
            canvas -> gx_canvas_created_previous -> gx_canvas_created_next = canvas -> gx_canvas_created_next;
83
3
            if (canvas -> gx_canvas_created_next)
84
            {
85
2
                canvas -> gx_canvas_created_next -> gx_canvas_created_previous = canvas -> gx_canvas_created_previous;
86
            }
87
        }
88
        else
89
        {
90
283
            _gx_system_canvas_created_list = canvas -> gx_canvas_created_next;
91
92
283
            if (_gx_system_canvas_created_list)
93
            {
94
282
                _gx_system_canvas_created_list -> gx_canvas_created_previous = GX_NULL;
95
            }
96
        }
97
98
286
        _gx_system_canvas_created_count--;
99
100
        /* Only for Win32, we sometimes have to create module 4 aligned scratch memory buffer */
101
        #ifdef GX_TARGET_WIN32
102
        if (canvas -> gx_canvas_padded_memory != GX_NULL)
103
        {
104
            free(canvas -> gx_canvas_padded_memory);
105
        }
106
        #endif
107
108
        /* Clear the screen control block.  */
109
286
        memset(canvas, 0, sizeof(GX_CANVAS));
110
    }
111
    /* unlock gx_system.  */
112
287
    GX_EXIT_CRITICAL
113
114
    /* Return successful status.  */
115
287
    return(GX_SUCCESS);
116
}
117