FreeBSD/sbin/hastd/nv.c
/*
 * Create nv structure based on ebuf received from the network.
 */
Create nv structure based on ebuf received from the network.
Create nv structure based on ebuf received from the network .
struct nv *
nv_ntoh(struct ebuf *eb)
{
	struct nv *nv;
	size_t extra;
	int rerrno;
	PJDLOG_ASSERT(eb != NULL);
	nv = malloc(sizeof(*nv));
	if (nv == NULL)
		return (NULL);
	nv->nv_error = 0;
	nv->nv_ebuf = eb;
	nv->nv_magic = NV_MAGIC;
	if (nv_validate(nv, &extra) == -1) {
		rerrno = errno;
		nv->nv_magic = 0;
		free(nv);
		errno = rerrno;
		return (NULL);
	}
	ebuf_del_tail(eb, extra);
	return (nv);
}
struct nv * nv_ntoh ( struct ebuf * eb ) { struct nv * nv ; size_t extra ; int rerrno ; PJDLOG_ASSERT ( eb != NULL ) ; nv = malloc ( sizeof ( * nv ) ) ; if ( nv == NULL ) return ( NULL ) ; nv -> nv_error = 0 ; nv -> nv_ebuf = eb ; nv -> nv_magic = NV_MAGIC ; if ( nv_validate ( nv , & extra ) == -1 ) { rerrno = errno ; nv -> nv_magic = 0 ; free ( nv ) ; errno = rerrno ; return ( NULL ) ; } ebuf_del_tail ( eb , extra ) ; return ( nv ) ; }
Create nv structure based on ebuf received from the network.
Create nv structure based on ebuf received from the network .
/*
	 * Remove extra zeros at the end of the buffer.
	 */