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

Function nvpair_allocv

freebsd/contrib/libnv/bsd_nvpair.c:117–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115}
116
117static nvpair_t *
118nvpair_allocv(const char *name, int type, uint64_t data, size_t datasize,
119 size_t nitems)
120{
121 nvpair_t *nvp;
122 size_t namelen;
123
124 PJDLOG_ASSERT(type >= NV_TYPE_FIRST && type <= NV_TYPE_LAST);
125
126 namelen = strlen(name);
127 if (namelen >= NV_NAME_MAX) {
128 ERRNO_SET(ENAMETOOLONG);
129 return (NULL);
130 }
131
132 nvp = nv_calloc(1, sizeof(*nvp) + namelen + 1);
133 if (nvp != NULL) {
134 nvp->nvp_name = (char *)(nvp + 1);
135 memcpy(nvp->nvp_name, name, namelen);
136 nvp->nvp_name[namelen] = '\0';
137 nvp->nvp_type = type;
138 nvp->nvp_data = data;
139 nvp->nvp_datasize = datasize;
140 nvp->nvp_nitems = nitems;
141 nvp->nvp_magic = NVPAIR_MAGIC;
142 }
143
144 return (nvp);
145}
146
147static int
148nvpair_append(nvpair_t *nvp, const void *value, size_t valsize, size_t datasize)

Callers 15

nvpair_create_nullFunction · 0.85
nvpair_create_boolFunction · 0.85
nvpair_create_numberFunction · 0.85
nvpair_create_stringFunction · 0.85
nvpair_create_nvlistFunction · 0.85
nvpair_create_descriptorFunction · 0.85
nvpair_create_binaryFunction · 0.85
nvpair_create_bool_arrayFunction · 0.85

Calls 1

memcpyFunction · 0.50

Tested by

no test coverage detected