common: New function nve_set

* common/name-value.c (nve_set): New.
--

Taken from 2.2 commit 706adf6691
This commit is contained in:
Werner Koch 2023-05-26 11:56:36 +02:00
parent f15a643a2d
commit ec0c35d1b8
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
2 changed files with 27 additions and 0 deletions

View File

@ -497,6 +497,30 @@ nvc_set (nvc_t pk, const char *name, const char *value)
}
/* Update entry E to VALUE. */
gpg_error_t
nve_set (nve_t e, const char *value)
{
char *v;
if (!e)
return GPG_ERR_INV_ARG;
v = xtrystrdup (value? value:"");
if (!v)
return my_error_from_syserror ();
free_strlist_wipe (e->raw_value);
e->raw_value = NULL;
if (e->value)
wipememory (e->value, strlen (e->value));
xfree (e->value);
e->value = v;
return 0;
}
/* Delete the given entry from PK. */
void
nvc_delete (nvc_t pk, nve_t entry)

View File

@ -92,6 +92,9 @@ gpg_error_t nvc_add (nvc_t pk, const char *name, const char *value);
first entry is updated. */
gpg_error_t nvc_set (nvc_t pk, const char *name, const char *value);
/* Update entry E to VALUE. */
gpg_error_t nve_set (nve_t e, const char *value);
/* Delete the given entry from PK. */
void nvc_delete (nvc_t pk, nve_t pke);