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

Function nvpair_unpack_number_array

freebsd/contrib/libnv/bsd_nvpair.c:930–964  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

928}
929
930const unsigned char *
931nvpair_unpack_number_array(bool isbe, nvpair_t *nvp, const unsigned char *ptr,
932 size_t *leftp)
933{
934 uint64_t *value;
935 size_t size;
936 unsigned int i;
937
938 PJDLOG_ASSERT(nvp->nvp_type == NV_TYPE_NUMBER_ARRAY);
939
940 size = sizeof(*value) * nvp->nvp_nitems;
941 if (nvp->nvp_datasize != size || *leftp < size ||
942 nvp->nvp_nitems == 0 || size < nvp->nvp_nitems) {
943 ERRNO_SET(EINVAL);
944 return (NULL);
945 }
946
947 value = nv_malloc(size);
948 if (value == NULL)
949 return (NULL);
950
951 for (i = 0; i < nvp->nvp_nitems; i++) {
952 if (isbe)
953 value[i] = be64dec(ptr);
954 else
955 value[i] = le64dec(ptr);
956
957 ptr += sizeof(*value);
958 *leftp -= sizeof(*value);
959 }
960
961 nvp->nvp_data = (uint64_t)(uintptr_t)value;
962
963 return (ptr);
964}
965
966const unsigned char *
967nvpair_unpack_string_array(bool isbe __unused, nvpair_t *nvp,

Callers 1

nvlist_xunpackFunction · 0.85

Calls 2

be64decFunction · 0.85
le64decFunction · 0.85

Tested by

no test coverage detected