]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Don't allocate memory for operations that do not insert
authorRyan Stone <rstone@FreeBSD.org>
Sun, 1 Mar 2015 00:22:31 +0000 (00:22 +0000)
committerRyan Stone <rstone@FreeBSD.org>
Sun, 1 Mar 2015 00:22:31 +0000 (00:22 +0000)
commited007c94ba70724d589deded7ab5d21f39ed9a94
tree0e1de0c66942e5907662e1732dd48d5bf9a9c667
parenta87e51626778b12f5679780a20e719b947aa103b
Don't allocate memory for operations that do not insert

Almost every operation performed on an nvlist was allocating a
new string to hold the key name.  The nvlist_exists* family of
functions would always return false if they failed to allocate
the string.  The rest of the functions would outright abort().
Fix the non-varargs variants of the functions to perform the
requested operations directly and the varargs versions to
allocate the string and call into the non-varargs versions.
The varargs versions are still broken and really can't be fixed,
so we might consider axing them entirely.  However, now the non-
varargs functions are always safe to call.

Differential Revision: https://reviews.freebsd.org/D1879
Reviewed by: pjd, jfv
MFC after: 1 month
Sponsored by: Sandvine Inc.
lib/libnv/dnvlist.c
lib/libnv/nv_impl.h
lib/libnv/nvlist.c