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

Function nvpair_pack_string_array

freebsd/contrib/libnv/bsd_nvpair.c:551–579  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

549}
550
551unsigned char *
552nvpair_pack_string_array(const nvpair_t *nvp, unsigned char *ptr, size_t *leftp)
553{
554 unsigned int ii;
555 size_t size, len;
556 const char * const *array;
557
558 NVPAIR_ASSERT(nvp);
559 PJDLOG_ASSERT(nvp->nvp_type == NV_TYPE_STRING_ARRAY);
560 PJDLOG_ASSERT(*leftp >= nvp->nvp_datasize);
561
562 size = 0;
563 array = nvpair_get_string_array(nvp, NULL);
564 PJDLOG_ASSERT(array != NULL);
565
566 for (ii = 0; ii < nvp->nvp_nitems; ii++) {
567 len = strlen(array[ii]) + 1;
568 PJDLOG_ASSERT(*leftp >= len);
569
570 memcpy(ptr, (const void *)array[ii], len);
571 size += len;
572 ptr += len;
573 *leftp -= len;
574 }
575
576 PJDLOG_ASSERT(size == nvp->nvp_datasize);
577
578 return (ptr);
579}
580
581#ifndef _KERNEL
582unsigned char *

Callers 1

nvlist_xpackFunction · 0.85

Calls 2

nvpair_get_string_arrayFunction · 0.85
memcpyFunction · 0.50

Tested by

no test coverage detected