mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
common: Add set_membuf_err.
* common/membuf.c (set_membuf_err): New.
This commit is contained in:
parent
038136ea48
commit
da39102216
@ -231,3 +231,15 @@ peek_membuf (membuf_t *mb, size_t *len)
|
|||||||
*len = mb->len;
|
*len = mb->len;
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* To assist using membuf with function returning an error, this
|
||||||
|
* function sets the membuf into the error state. */
|
||||||
|
void
|
||||||
|
set_membuf_err (membuf_t *mb, gpg_error_t err)
|
||||||
|
{
|
||||||
|
if (!mb->out_of_core)
|
||||||
|
{
|
||||||
|
int myerr = gpg_err_code_to_errno (gpg_err_code (err));
|
||||||
|
mb->out_of_core = myerr? myerr : EINVAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -60,5 +60,6 @@ void put_membuf_printf (membuf_t *mb, const char *format,
|
|||||||
void *get_membuf (membuf_t *mb, size_t *len);
|
void *get_membuf (membuf_t *mb, size_t *len);
|
||||||
void *get_membuf_shrink (membuf_t *mb, size_t *len);
|
void *get_membuf_shrink (membuf_t *mb, size_t *len);
|
||||||
const void *peek_membuf (membuf_t *mb, size_t *len);
|
const void *peek_membuf (membuf_t *mb, size_t *len);
|
||||||
|
void set_membuf_err (membuf_t *mb, gpg_error_t err);
|
||||||
|
|
||||||
#endif /*GNUPG_COMMON_MEMBUF_H*/
|
#endif /*GNUPG_COMMON_MEMBUF_H*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user