gdbstub: Do not use memset() on GByteArray

Introduce gdb_get_zeroes() to fill a GByteArray with zeroes.

Fixes: a010bdbe71 ("extend GByteArray to read register helpers")
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20200414102427.7459-1-philmd@redhat.com>
[AJB: used slightly more gliby set_size approach]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20200414200631.12799-13-alex.bennee@linaro.org>
This commit is contained in:
Philippe Mathieu-Daudé 2020-04-14 21:06:26 +01:00 committed by Alex Bennée
parent bbc40fefce
commit 7b8c1527ae
3 changed files with 12 additions and 6 deletions

View file

@ -125,6 +125,15 @@ static inline int gdb_get_reg128(GByteArray *buf, uint64_t val_hi,
return 16;
}
static inline int gdb_get_zeroes(GByteArray *array, size_t len)
{
guint oldlen = array->len;
g_byte_array_set_size(array, oldlen + len);
memset(array->data + oldlen, 0, len);
return len;
}
/**
* gdb_get_reg_ptr: get pointer to start of last element
* @len: length of element