GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: fx_file_best_effort_allocate.c Lines: 5 5 100.0 %
Date: 2026-03-06 18:49:02 Branches: 2 2 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
/** FileX Component                                                       */
17
/**                                                                       */
18
/**   File                                                                */
19
/**                                                                       */
20
/**************************************************************************/
21
/**************************************************************************/
22
23
#define FX_SOURCE_CODE
24
25
26
/* Include necessary system files.  */
27
28
#include "fx_api.h"
29
#include "fx_file.h"
30
31
32
/**************************************************************************/
33
/*                                                                        */
34
/*  FUNCTION                                               RELEASE        */
35
/*                                                                        */
36
/*    _fx_file_best_effort_allocate                       PORTABLE C      */
37
/*                                                           6.1          */
38
/*  AUTHOR                                                                */
39
/*                                                                        */
40
/*    William E. Lamie, Microsoft Corporation                             */
41
/*                                                                        */
42
/*  DESCRIPTION                                                           */
43
/*                                                                        */
44
/*    This function attempts to allocate the number of consecutive        */
45
/*    clusters required to satisfy the user's request.  If there are not  */
46
/*    enough clusters, the largest set of clusters are allocated and      */
47
/*    linked to the file.  If there are no free clusters, an error        */
48
/*    code is returned to the caller.                                     */
49
/*                                                                        */
50
/*  INPUT                                                                 */
51
/*                                                                        */
52
/*    file_ptr                              File control block pointer    */
53
/*    size                                  Number of bytes to allocate   */
54
/*    actual_size_allocated                 Number of bytes allocated     */
55
/*                                                                        */
56
/*  OUTPUT                                                                */
57
/*                                                                        */
58
/*    return status                                                       */
59
/*                                                                        */
60
/*  CALLS                                                                 */
61
/*                                                                        */
62
/*    _fx_file_extended_best_effort_allocate                              */
63
/*                                          Allocate the largest set of   */
64
/*                                            clusters                    */
65
/*                                                                        */
66
/*  CALLED BY                                                             */
67
/*                                                                        */
68
/*    Application Code                                                    */
69
/*                                                                        */
70
/**************************************************************************/
71
2
UINT  _fx_file_best_effort_allocate(FX_FILE *file_ptr, ULONG size, ULONG *actual_size_allocated)
72
{
73
74
UINT    status;
75
ULONG64 temp_actual_size_allocated;
76
77
    /* Call actual best effort file allocate service.  */
78
2
    status = _fx_file_extended_best_effort_allocate(file_ptr, (ULONG64)size, &temp_actual_size_allocated);
79
80
    /* Check status.  */
81
2
    if (status == FX_SUCCESS)
82
    {
83
1
        *actual_size_allocated = (ULONG)temp_actual_size_allocated;
84
    }
85
86
    /* Return status to the caller.  */
87
2
    return(status);
88
}
89