1
10
13
14
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
104
105
106
107
108
109
110
111
112
113
115
116
117
118
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
...
...
...
#define UX_SOURCE_CODE
#include "ux_api.h"
...
...
UX_MEMORY_BLOCK *_ux_utility_memory_free_block_best_get(ULONG memory_cache_flag,
ULONG memory_size_requested)
{
UX_MEMORY_BLOCK *memory_block;
UX_MEMORY_BLOCK *best_memory_block;
best_memory_block = UX_NULL;
switch (memory_cache_flag)
{
case UX_REGULAR_MEMORY :
memory_block = _ux_system -> ux_system_regular_memory_pool_start;
break;
case UX_REGULAR_MEMORY :
case UX_CACHE_SAFE_MEMORY :
memory_block = _ux_system -> ux_system_cache_safe_memory_pool_start;
break;
case UX_CACHE_SAFE_MEMORY :
default :
return(UX_NULL);
default
}switch (memory_cache_flag) { ... }
while (memory_block != UX_NULL)
{
if (memory_block -> ux_memory_block_status == UX_MEMORY_UNUSED)
{
/* ... */
if (memory_block -> ux_memory_block_size > memory_size_requested)
{
/* ... */
if (best_memory_block == UX_NULL)
best_memory_block = memory_block;
else
{
if (memory_block -> ux_memory_block_size < best_memory_block -> ux_memory_block_size)
best_memory_block = memory_block;
}else { ... }
}if (memory_block -> ux_memory_block_size > memory_size_requested) { ... }
}if (memory_block -> ux_memory_block_status == UX_MEMORY_UNUSED) { ... }
memory_block = memory_block -> ux_memory_block_next;
}while (memory_block != UX_NULL) { ... }
return(best_memory_block);
}{ ... }
...