MCPcopy Create free account
hub / github.com/F-Stack/f-stack / nvpair_create_number_array

Function nvpair_create_number_array

freebsd/contrib/libnv/bsd_nvpair.c:1348–1376  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1346}
1347
1348nvpair_t *
1349nvpair_create_number_array(const char *name, const uint64_t *value,
1350 size_t nitems)
1351{
1352 nvpair_t *nvp;
1353 size_t size;
1354 void *data;
1355
1356 if (value == NULL || nitems == 0) {
1357 ERRNO_SET(EINVAL);
1358 return (NULL);
1359 }
1360
1361 size = sizeof(value[0]) * nitems;
1362 data = nv_malloc(size);
1363 if (data == NULL)
1364 return (NULL);
1365
1366 memcpy(data, value, size);
1367 nvp = nvpair_allocv(name, NV_TYPE_NUMBER_ARRAY,
1368 (uint64_t)(uintptr_t)data, size, nitems);
1369 if (nvp == NULL) {
1370 ERRNO_SAVE();
1371 nv_free(data);
1372 ERRNO_RESTORE();
1373 }
1374
1375 return (nvp);
1376}
1377
1378nvpair_t *
1379nvpair_create_string_array(const char *name, const char * const *value,

Callers 1

nvpair_cloneFunction · 0.85

Calls 2

nvpair_allocvFunction · 0.85
memcpyFunction · 0.50

Tested by

no test coverage detected