diff options
author | Alexander Larsson <alexl@redhat.com> | 2010-06-29 21:23:55 +0200 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2010-06-30 22:35:17 +0200 |
commit | 0f5a6f57b70bb7c94e15e908db4627d44c339b9c (patch) | |
tree | df2f77163a52b5879dd6944aa04fb8e41b0f9c3f | |
parent | 5cd86fc45dfa94cb08c3316c614923ff50b94b0f (diff) | |
download | spice-0f5a6f57b70bb7c94e15e908db4627d44c339b9c.tar.gz spice-0f5a6f57b70bb7c94e15e908db4627d44c339b9c.tar.xz spice-0f5a6f57b70bb7c94e15e908db4627d44c339b9c.zip |
Add spice_marshaller_set_uint32
With this function you can update an added uint32 after it being added.
To make this possible all the spice_marshaller_add_add_foo functions
now return a pointer that can be used as a reference when later
setting a value.
-rw-r--r-- | common/marshaller.c | 29 | ||||
-rw-r--r-- | common/marshaller.h | 18 |
2 files changed, 31 insertions, 16 deletions
diff --git a/common/marshaller.c b/common/marshaller.c index ece4f486..be6198dc 100644 --- a/common/marshaller.c +++ b/common/marshaller.c @@ -526,66 +526,79 @@ int spice_marshaller_fill_iovec(SpiceMarshaller *m, struct iovec *vec, } #endif -void spice_marshaller_add_uint64(SpiceMarshaller *m, uint64_t v) +void *spice_marshaller_add_uint64(SpiceMarshaller *m, uint64_t v) { uint8_t *ptr; ptr = spice_marshaller_reserve_space(m, sizeof(uint64_t)); write_uint64(ptr, v); + return (void *)ptr; } -void spice_marshaller_add_int64(SpiceMarshaller *m, int64_t v) +void *spice_marshaller_add_int64(SpiceMarshaller *m, int64_t v) { uint8_t *ptr; ptr = spice_marshaller_reserve_space(m, sizeof(int64_t)); write_int64(ptr, v); + return (void *)ptr; } -void spice_marshaller_add_uint32(SpiceMarshaller *m, uint32_t v) +void *spice_marshaller_add_uint32(SpiceMarshaller *m, uint32_t v) { uint8_t *ptr; ptr = spice_marshaller_reserve_space(m, sizeof(uint32_t)); write_uint32(ptr, v); + return (void *)ptr; } -void spice_marshaller_add_int32(SpiceMarshaller *m, int32_t v) +void spice_marshaller_set_uint32(SpiceMarshaller *m, void *ref, uint32_t v) +{ + write_uint32((uint8_t *)ref, v); +} + +void *spice_marshaller_add_int32(SpiceMarshaller *m, int32_t v) { uint8_t *ptr; ptr = spice_marshaller_reserve_space(m, sizeof(int32_t)); write_int32(ptr, v); + return (void *)ptr; } -void spice_marshaller_add_uint16(SpiceMarshaller *m, uint16_t v) +void *spice_marshaller_add_uint16(SpiceMarshaller *m, uint16_t v) { uint8_t *ptr; ptr = spice_marshaller_reserve_space(m, sizeof(uint16_t)); write_uint16(ptr, v); + return (void *)ptr; } -void spice_marshaller_add_int16(SpiceMarshaller *m, int16_t v) +void *spice_marshaller_add_int16(SpiceMarshaller *m, int16_t v) { uint8_t *ptr; ptr = spice_marshaller_reserve_space(m, sizeof(int16_t)); write_int16(ptr, v); + return (void *)ptr; } -void spice_marshaller_add_uint8(SpiceMarshaller *m, uint8_t v) +void *spice_marshaller_add_uint8(SpiceMarshaller *m, uint8_t v) { uint8_t *ptr; ptr = spice_marshaller_reserve_space(m, sizeof(uint8_t)); write_uint8(ptr, v); + return (void *)ptr; } -void spice_marshaller_add_int8(SpiceMarshaller *m, int8_t v) +void *spice_marshaller_add_int8(SpiceMarshaller *m, int8_t v) { uint8_t *ptr; ptr = spice_marshaller_reserve_space(m, sizeof(int8_t)); write_int8(ptr, v); + return (void *)ptr; } diff --git a/common/marshaller.h b/common/marshaller.h index a60e97b4..59a190dc 100644 --- a/common/marshaller.h +++ b/common/marshaller.h @@ -50,13 +50,15 @@ SpiceMarshaller *spice_marshaller_get_ptr_submarshaller(SpiceMarshaller *m, int int spice_marshaller_fill_iovec(SpiceMarshaller *m, struct iovec *vec, int n_vec, size_t skip_bytes); #endif -void spice_marshaller_add_uint64(SpiceMarshaller *m, uint64_t v); -void spice_marshaller_add_int64(SpiceMarshaller *m, int64_t v); -void spice_marshaller_add_uint32(SpiceMarshaller *m, uint32_t v); -void spice_marshaller_add_int32(SpiceMarshaller *m, int32_t v); -void spice_marshaller_add_uint16(SpiceMarshaller *m, uint16_t v); -void spice_marshaller_add_int16(SpiceMarshaller *m, int16_t v); -void spice_marshaller_add_uint8(SpiceMarshaller *m, uint8_t v); -void spice_marshaller_add_int8(SpiceMarshaller *m, int8_t v); +void *spice_marshaller_add_uint64(SpiceMarshaller *m, uint64_t v); +void *spice_marshaller_add_int64(SpiceMarshaller *m, int64_t v); +void *spice_marshaller_add_uint32(SpiceMarshaller *m, uint32_t v); +void *spice_marshaller_add_int32(SpiceMarshaller *m, int32_t v); +void *spice_marshaller_add_uint16(SpiceMarshaller *m, uint16_t v); +void *spice_marshaller_add_int16(SpiceMarshaller *m, int16_t v); +void *spice_marshaller_add_uint8(SpiceMarshaller *m, uint8_t v); +void *spice_marshaller_add_int8(SpiceMarshaller *m, int8_t v); + +void spice_marshaller_set_uint32(SpiceMarshaller *m, void *ref, uint32_t v); #endif |