mirror of
https://gitlab.freedesktop.org/plymouth/plymouth.git
synced 2026-05-09 04:48:08 +02:00
Merge branch 'nullify-borrowed-bytes' into 'main'
ply-buffer: Nullify bytes outside scope block See merge request plymouth/plymouth!262
This commit is contained in:
commit
f5e0b9e06c
1 changed files with 12 additions and 6 deletions
|
|
@ -55,12 +55,18 @@ void ply_buffer_remove_bytes_at_end (ply_buffer_t *buffer,
|
|||
const char *ply_buffer_get_bytes (ply_buffer_t *buffer);
|
||||
size_t ply_buffer_get_capacity (ply_buffer_t *buffer);
|
||||
char *ply_buffer_steal_bytes (ply_buffer_t *buffer);
|
||||
#define ply_buffer_borrow_bytes(buffer, bytes, size, capacity) \
|
||||
for (bool _ran = false; *bytes = (char *) ply_buffer_get_bytes (buffer), \
|
||||
*size = ply_buffer_get_size (buffer), \
|
||||
*capacity = ply_buffer_get_capacity (buffer), \
|
||||
!_ran; \
|
||||
ply_buffer_set_bytes (buffer, *bytes, *size, *capacity), _ran = true)
|
||||
#define ply_buffer_borrow_bytes(buffer, bytes, size, capacity) \
|
||||
for (bool _ran = false; \
|
||||
!_ran && (*bytes = (char *) ply_buffer_get_bytes (buffer), \
|
||||
*size = ply_buffer_get_size (buffer), \
|
||||
*capacity = ply_buffer_get_capacity (buffer)), \
|
||||
!_ran; \
|
||||
ply_buffer_set_bytes (buffer, *bytes, *size, *capacity), \
|
||||
_ran = true, \
|
||||
*bytes = NULL, \
|
||||
*size = 0, \
|
||||
*capacity = 0)
|
||||
|
||||
size_t ply_buffer_get_size (ply_buffer_t *buffer);
|
||||
void ply_buffer_clear (ply_buffer_t *buffer);
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue