1 /**************************************************************************/
2 /* */
3 /* Copyright (c) Microsoft Corporation. All rights reserved. */
4 /* */
5 /* This software is licensed under the Microsoft Software License */
6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */
7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
8 /* and in the root directory of this software. */
9 /* */
10 /**************************************************************************/
11
12
13 /**************************************************************************/
14 /**************************************************************************/
15 /** */
16 /** USBX Component */
17 /** */
18 /** Utility */
19 /** */
20 /**************************************************************************/
21 /**************************************************************************/
22
23
24 /* Include necessary system files. */
25
26 #define UX_SOURCE_CODE
27
28 #include "ux_api.h"
29
30
31 /**************************************************************************/
32 /* */
33 /* FUNCTION RELEASE */
34 /* */
35 /* _ux_utility_string_length_get PORTABLE C */
36 /* 6.1 */
37 /* AUTHOR */
38 /* */
39 /* Chaoqiong Xiao, Microsoft Corporation */
40 /* */
41 /* DESCRIPTION */
42 /* */
43 /* This function derives the length of a NULL-terminated string. */
44 /* */
45 /* This function is deprecated, for the possible issue of operating on */
46 /* a buffer that is not NULL-terminated. As a replacement, */
47 /* _ux_utility_string_length_check should be used, where the length of */
48 /* the buffer is introduced to validate the string by checking for the */
49 /* NULL-terminator within the buffer length. */
50 /* */
51 /* INPUT */
52 /* */
53 /* string Pointer to string */
54 /* */
55 /* OUTPUT */
56 /* */
57 /* length of string */
58 /* */
59 /* CALLS */
60 /* */
61 /* None */
62 /* */
63 /* CALLED BY */
64 /* */
65 /* USBX Components */
66 /* */
67 /* RELEASE HISTORY */
68 /* */
69 /* DATE NAME DESCRIPTION */
70 /* */
71 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
72 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
73 /* resulting in version 6.1 */
74 /* */
75 /**************************************************************************/
_ux_utility_string_length_get(UCHAR * string)76 ULONG _ux_utility_string_length_get(UCHAR *string)
77 {
78
79 ULONG length = 0;
80
81 /* Loop to find the length of the string. */
82 length = 0;
83 while (string[length])
84 {
85
86 /* Move to next position. */
87 length++;
88 }
89
90 /* Return length to caller. */
91 return(length);
92 }
93
94