MCPcopy Create free account
hub / github.com/KaisenAmin/c_std / tuple_make_tuple

Function tuple_make_tuple

tuple/tuple.c:190–218  ·  view source on GitHub ↗

* @brief This function creates a new tuple with the specified number of elements. * Each element in the tuple is set using the provided data and its corresponding size. * * @param num The number of elements to store in the tuple. * @param ... A variable number of arguments, each consisting of a pointer to data followed by a `size_t` indicating the size of the data. * @return A pointer to th

Source from the content-addressed store, hash-verified

188 * @note The data provided is copied into the tuple, and the caller is responsible for managing the memory of the original data.
189 */
190Tuple* tuple_make_tuple(size_t num, ...) {
191 TUPLE_LOG("[tuple_make_tuple]: Entering with num: %zu", num);
192
193 Tuple* tuple = tuple_create(num);
194 if (!tuple) {
195 TUPLE_LOG("[tuple_make_tuple]: Error: Creation of tuple failed.");
196 return NULL;
197 }
198
199 va_list args;
200 va_start(args, num);
201
202 for (size_t i = 0; i < num; ++i) {
203 void* data = va_arg(args, void*);
204 size_t size = va_arg(args, size_t);
205 if (!tuple_set(tuple, i, data, size)) {
206 TUPLE_LOG("[tuple_make_tuple]: Error: Failed to set data at index %zu.", i);
207 tuple_deallocate(tuple);
208 va_end(args);
209
210 return NULL;
211 }
212 TUPLE_LOG("[tuple_make_tuple]: Set data at index %zu.", i);
213 }
214 va_end(args);
215
216 TUPLE_LOG("[tuple_make_tuple]: Returning tuple: %p", (void*)tuple);
217 return tuple;
218}
219
220
221/**

Callers

nothing calls this directly

Calls 3

tuple_createFunction · 0.85
tuple_setFunction · 0.85
tuple_deallocateFunction · 0.85

Tested by

no test coverage detected