[serialize] Copy both sides of the buffer
This commit is contained in:
parent
8512dc565d
commit
946d446f9b
@ -249,13 +249,18 @@ struct hb_serialize_context_t
|
|||||||
hb_bytes_t copy_bytes () const
|
hb_bytes_t copy_bytes () const
|
||||||
{
|
{
|
||||||
assert (this->successful);
|
assert (this->successful);
|
||||||
unsigned int len = this->head - this->start;
|
/* Copy both items from head side and tail side... */
|
||||||
void *p = malloc (len);
|
unsigned int len = (this->head - this->start)
|
||||||
|
+ (this->end - this->tail);
|
||||||
|
char *p = (char *) malloc (len);
|
||||||
if (p)
|
if (p)
|
||||||
memcpy (p, this->start, len);
|
{
|
||||||
|
memcpy (p, this->start, this->head - this->start);
|
||||||
|
memcpy (p + (this->head - this->start), this->tail, this->end - this->tail);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return hb_bytes_t ();
|
return hb_bytes_t ();
|
||||||
return hb_bytes_t ((char *) p, len);
|
return hb_bytes_t (p, len);
|
||||||
}
|
}
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
Type *copy () const
|
Type *copy () const
|
||||||
|
Loading…
Reference in New Issue
Block a user