-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnode-list-mutators.c
325 lines (299 loc) · 9.79 KB
/
node-list-mutators.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
/***************************************************************************
* This file is automatically generated by gen-get-set. Be sure to keep
* track of any manual changes.
*
* These generated functions are not expected to be perfect. Check and
* edit as needed before adding to your code.
***************************************************************************/
#include <string.h>
#include <ctype.h>
#include <stdbool.h> // In case of bool
#include <stdint.h> // In case of int64_t, etc
#include <xtend/string.h> // strlcpy() on Linux
#include "node-list-private.h"
/***************************************************************************
* Library:
* #include <node-list.h>
*
*
* Description:
* Mutator for head_node member in a node_list_t structure.
* Use this function to set head_node in a node_list_t object
* from non-member functions. This function performs a direct
* assignment for scalar or pointer structure members. If
* head_node is a pointer, data previously pointed to should
* be freed before calling this function to avoid memory
* leaks.
*
* Arguments:
* node_list_ptr Pointer to the structure to set
* new_head_node The new value for head_node
*
* Returns:
* NODE_LIST_DATA_OK if the new value is acceptable and assigned
* NODE_LIST_DATA_OUT_OF_RANGE otherwise
*
* Examples:
* node_list_t node_list;
* char * new_head_node;
*
* if ( node_list_set_head_node(&node_list, new_head_node)
* == NODE_LIST_DATA_OK )
* {
* }
*
* See also:
* (3)
*
* History:
* Date Name Modification
* 2024-02-23 gen-get-set Auto-generated from node-list-private.h
***************************************************************************/
int node_list_set_head_node(node_list_t *node_list_ptr, char * new_head_node)
{
if ( new_head_node == NULL )
return NODE_LIST_DATA_OUT_OF_RANGE;
else
{
node_list_ptr->head_node = new_head_node;
return NODE_LIST_DATA_OK;
}
}
/***************************************************************************
* Library:
* #include <node-list.h>
*
*
* Description:
* Mutator for an array element of head_node member in a node_list_t
* structure. Use this function to set node_list_ptr->head_node[c]
* in a node_list_t object from non-member functions.
*
* Arguments:
* node_list_ptr Pointer to the structure to set
* c Subscript to the head_node array
* new_head_node_element The new value for head_node[c]
*
* Returns:
* NODE_LIST_DATA_OK if the new value is acceptable and assigned
* NODE_LIST_DATA_OUT_OF_RANGE otherwise
*
* Examples:
* node_list_t node_list;
* size_t c;
* char * new_head_node_element;
*
* if ( node_list_set_head_node_ae(&node_list, c, new_head_node_element)
* == NODE_LIST_DATA_OK )
* {
* }
*
* See also:
* NODE_LIST_SET_HEAD_NODE_AE(3)
*
* History:
* Date Name Modification
* 2024-02-23 gen-get-set Auto-generated from node-list-private.h
***************************************************************************/
int node_list_set_head_node_ae(node_list_t *node_list_ptr, size_t c, char new_head_node_element)
{
if ( false )
return NODE_LIST_DATA_OUT_OF_RANGE;
else
{
node_list_ptr->head_node[c] = new_head_node_element;
return NODE_LIST_DATA_OK;
}
}
/***************************************************************************
* Library:
* #include <node-list.h>
*
*
* Description:
* Mutator for head_node member in a node_list_t structure.
* Use this function to set head_node in a node_list_t object
* from non-member functions. This function copies the array pointed to
* by new_head_node to node_list_ptr->head_node.
*
* Arguments:
* node_list_ptr Pointer to the structure to set
* new_head_node The new value for head_node
* array_size Size of the head_node array.
*
* Returns:
* NODE_LIST_DATA_OK if the new value is acceptable and assigned
* NODE_LIST_DATA_OUT_OF_RANGE otherwise
*
* Examples:
* node_list_t node_list;
* char * new_head_node;
* size_t array_size;
*
* if ( node_list_set_head_node_cpy(&node_list, new_head_node, array_size)
* == NODE_LIST_DATA_OK )
* {
* }
*
* See also:
* NODE_LIST_SET_HEAD_NODE(3)
*
* History:
* Date Name Modification
* 2024-02-23 gen-get-set Auto-generated from node-list-private.h
***************************************************************************/
int node_list_set_head_node_cpy(node_list_t *node_list_ptr, char * new_head_node, size_t array_size)
{
if ( new_head_node == NULL )
return NODE_LIST_DATA_OUT_OF_RANGE;
else
{
// FIXME: Assuming char array is a null-terminated string
strlcpy(node_list_ptr->head_node, new_head_node, array_size);
return NODE_LIST_DATA_OK;
}
}
/***************************************************************************
* Library:
* #include <node-list.h>
*
*
* Description:
* Mutator for compute_node_count member in a node_list_t structure.
* Use this function to set compute_node_count in a node_list_t object
* from non-member functions. This function performs a direct
* assignment for scalar or pointer structure members. If
* compute_node_count is a pointer, data previously pointed to should
* be freed before calling this function to avoid memory
* leaks.
*
* Arguments:
* node_list_ptr Pointer to the structure to set
* new_compute_node_count The new value for compute_node_count
*
* Returns:
* NODE_LIST_DATA_OK if the new value is acceptable and assigned
* NODE_LIST_DATA_OUT_OF_RANGE otherwise
*
* Examples:
* node_list_t node_list;
* unsigned new_compute_node_count;
*
* if ( node_list_set_compute_node_count(&node_list, new_compute_node_count)
* == NODE_LIST_DATA_OK )
* {
* }
*
* See also:
* (3)
*
* History:
* Date Name Modification
* 2024-02-23 gen-get-set Auto-generated from node-list-private.h
***************************************************************************/
int node_list_set_compute_node_count(node_list_t *node_list_ptr, unsigned new_compute_node_count)
{
if ( false )
return NODE_LIST_DATA_OUT_OF_RANGE;
else
{
node_list_ptr->compute_node_count = new_compute_node_count;
return NODE_LIST_DATA_OK;
}
}
/***************************************************************************
* Library:
* #include <node-list.h>
*
*
* Description:
* Mutator for an array element of compute_nodes member in a node_list_t
* structure. Use this function to set node_list_ptr->compute_nodes[c]
* in a node_list_t object from non-member functions.
*
* Arguments:
* node_list_ptr Pointer to the structure to set
* c Subscript to the compute_nodes array
* new_compute_nodes_element The new value for compute_nodes[c]
*
* Returns:
* NODE_LIST_DATA_OK if the new value is acceptable and assigned
* NODE_LIST_DATA_OUT_OF_RANGE otherwise
*
* Examples:
* node_list_t node_list;
* size_t c;
* node_t * new_compute_nodes_element;
*
* if ( node_list_set_compute_nodes_ae(&node_list, c, new_compute_nodes_element)
* == NODE_LIST_DATA_OK )
* {
* }
*
* See also:
* NODE_LIST_SET_COMPUTE_NODES_AE(3)
*
* History:
* Date Name Modification
* 2024-02-23 gen-get-set Auto-generated from node-list-private.h
***************************************************************************/
int node_list_set_compute_nodes_ae(node_list_t *node_list_ptr, size_t c, node_t *new_compute_nodes_element)
{
if ( false )
return NODE_LIST_DATA_OUT_OF_RANGE;
else
{
node_list_ptr->compute_nodes[c] = new_compute_nodes_element;
return NODE_LIST_DATA_OK;
}
}
/***************************************************************************
* Library:
* #include <node-list.h>
*
*
* Description:
* Mutator for compute_nodes member in a node_list_t structure.
* Use this function to set compute_nodes in a node_list_t object
* from non-member functions. This function copies the array pointed to
* by new_compute_nodes to node_list_ptr->compute_nodes.
*
* Arguments:
* node_list_ptr Pointer to the structure to set
* new_compute_nodes The new value for compute_nodes
* array_size Size of the compute_nodes array.
*
* Returns:
* NODE_LIST_DATA_OK if the new value is acceptable and assigned
* NODE_LIST_DATA_OUT_OF_RANGE otherwise
*
* Examples:
* node_list_t node_list;
* node_t * new_compute_nodes;
* size_t array_size;
*
* if ( node_list_set_compute_nodes_cpy(&node_list, new_compute_nodes, array_size)
* == NODE_LIST_DATA_OK )
* {
* }
*
* See also:
* NODE_LIST_SET_COMPUTE_NODES(3)
*
* History:
* Date Name Modification
* 2024-02-23 gen-get-set Auto-generated from node-list-private.h
***************************************************************************/
int node_list_set_compute_nodes_cpy(node_list_t *node_list_ptr, node_t * new_compute_nodes[], size_t array_size)
{
if ( new_compute_nodes == NULL )
return NODE_LIST_DATA_OUT_OF_RANGE;
else
{
size_t c;
// FIXME: Assuming all elements should be copied
for (c = 0; c < array_size; ++c)
node_list_ptr->compute_nodes[c] = new_compute_nodes[c];
return NODE_LIST_DATA_OK;
}
}