mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice-common
synced 2026-08-08 11:58:41 +00:00
Marshaller: rename _add_ref() to _add_by_ref()
The spice_marshaller_add_ref() family of functions is confusing since it sounds like you're incrementing a reference on the marshaller. What it is actually doing is adding a data buffer to the marshaller by reference rather than by value. Changing the function names to _add_by_ref() makes this clearer. The old functions are deprecated and are simply inline functions that call the new functions. Acked-by: Christophe Fergeau <cfergeau@redhat.com>
This commit is contained in:
parent
a5871c80a9
commit
adb36c6185
@ -317,8 +317,8 @@ void spice_marshaller_unreserve_space(SpiceMarshaller *m, size_t size)
|
||||
item->len -= size;
|
||||
}
|
||||
|
||||
uint8_t *spice_marshaller_add_ref_full(SpiceMarshaller *m, uint8_t *data, size_t size,
|
||||
spice_marshaller_item_free_func free_data, void *opaque)
|
||||
uint8_t *spice_marshaller_add_by_ref_full(SpiceMarshaller *m, uint8_t *data, size_t size,
|
||||
spice_marshaller_item_free_func free_data, void *opaque)
|
||||
{
|
||||
MarshallerItem *item;
|
||||
SpiceMarshallerData *d;
|
||||
@ -349,21 +349,21 @@ uint8_t *spice_marshaller_add(SpiceMarshaller *m, const uint8_t *data, size_t si
|
||||
return ptr;
|
||||
}
|
||||
|
||||
uint8_t *spice_marshaller_add_ref(SpiceMarshaller *m, const uint8_t *data, size_t size)
|
||||
uint8_t *spice_marshaller_add_by_ref(SpiceMarshaller *m, const uint8_t *data, size_t size)
|
||||
{
|
||||
/* the cast to no-const here is safe as data is used for writing only if
|
||||
* free_data pointer is not NULL
|
||||
*/
|
||||
return spice_marshaller_add_ref_full(m, (uint8_t *) data, size, NULL, NULL);
|
||||
return spice_marshaller_add_by_ref_full(m, (uint8_t *) data, size, NULL, NULL);
|
||||
}
|
||||
|
||||
void spice_marshaller_add_ref_chunks(SpiceMarshaller *m, SpiceChunks *chunks)
|
||||
void spice_marshaller_add_chunks_by_ref(SpiceMarshaller *m, SpiceChunks *chunks)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < chunks->num_chunks; i++) {
|
||||
spice_marshaller_add_ref(m, chunks->chunk[i].data,
|
||||
chunks->chunk[i].len);
|
||||
spice_marshaller_add_by_ref(m, chunks->chunk[i].data,
|
||||
chunks->chunk[i].len);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -38,10 +38,23 @@ void spice_marshaller_destroy(SpiceMarshaller *m);
|
||||
uint8_t *spice_marshaller_reserve_space(SpiceMarshaller *m, size_t size);
|
||||
void spice_marshaller_unreserve_space(SpiceMarshaller *m, size_t size);
|
||||
uint8_t *spice_marshaller_add(SpiceMarshaller *m, const uint8_t *data, size_t size);
|
||||
uint8_t *spice_marshaller_add_ref(SpiceMarshaller *m, const uint8_t *data, size_t size);
|
||||
uint8_t *spice_marshaller_add_ref_full(SpiceMarshaller *m, uint8_t *data, size_t size,
|
||||
spice_marshaller_item_free_func free_data, void *opaque);
|
||||
void spice_marshaller_add_ref_chunks(SpiceMarshaller *m, SpiceChunks *chunks);
|
||||
uint8_t *spice_marshaller_add_by_ref(SpiceMarshaller *m, const uint8_t *data, size_t size);
|
||||
uint8_t *spice_marshaller_add_by_ref_full(SpiceMarshaller *m, uint8_t *data, size_t size,
|
||||
spice_marshaller_item_free_func free_data, void *opaque);
|
||||
void spice_marshaller_add_chunks_by_ref(SpiceMarshaller *m, SpiceChunks *chunks);
|
||||
SPICE_GNUC_DEPRECATED inline uint8_t *spice_marshaller_add_ref(SpiceMarshaller *m, const uint8_t *data, size_t size)
|
||||
{
|
||||
return spice_marshaller_add_by_ref(m, data, size);
|
||||
}
|
||||
SPICE_GNUC_DEPRECATED inline uint8_t *spice_marshaller_add_ref_full(SpiceMarshaller *m, uint8_t *data, size_t size,
|
||||
spice_marshaller_item_free_func free_data, void *opaque)
|
||||
{
|
||||
return spice_marshaller_add_by_ref_full(m, data, size, free_data, opaque);
|
||||
}
|
||||
SPICE_GNUC_DEPRECATED inline void spice_marshaller_add_ref_chunks(SpiceMarshaller *m, SpiceChunks *chunks)
|
||||
{
|
||||
spice_marshaller_add_chunks_by_ref(m, chunks);
|
||||
}
|
||||
void spice_marshaller_flush(SpiceMarshaller *m);
|
||||
void spice_marshaller_set_base(SpiceMarshaller *m, size_t base);
|
||||
uint8_t *spice_marshaller_linearize(SpiceMarshaller *m, size_t skip,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user