From 267d0133fff6af4153311c612fed12e1bc121ec3 Mon Sep 17 00:00:00 2001 From: "bjornv@webrtc.org" Date: Wed, 28 Dec 2011 10:26:17 +0000 Subject: [PATCH] Fixed pointer operations on void. This should fix the error on Win where pointer arithmetics are done on void pointers. Type cast to char to interpret a size. Review URL: http://webrtc-codereview.appspot.com/329019 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1300 4adac7df-926f-26a2-2b94-8c16560cd09d --- src/modules/audio_processing/utility/ring_buffer.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/modules/audio_processing/utility/ring_buffer.c b/src/modules/audio_processing/utility/ring_buffer.c index 7177ce3b1..6f9be3187 100644 --- a/src/modules/audio_processing/utility/ring_buffer.c +++ b/src/modules/audio_processing/utility/ring_buffer.c @@ -59,12 +59,12 @@ static size_t GetBufferReadRegions(buf_t* buf, // Check to see if read is not contiguous. if (read_elements > margin) { // Write data in two blocks that wrap the buffer. - *data_ptr_1 = buf->data + (buf->read_pos * buf->element_size); + *data_ptr_1 = ((char*) buf->data) + (buf->read_pos * buf->element_size); *data_ptr_bytes_1 = margin * buf->element_size; *data_ptr_2 = buf->data; *data_ptr_bytes_2 = (read_elements - margin) * buf->element_size; } else { - *data_ptr_1 = buf->data + (buf->read_pos * buf->element_size); + *data_ptr_1 = ((char*) buf->data) + (buf->read_pos * buf->element_size); *data_ptr_bytes_1 = read_elements * buf->element_size; *data_ptr_2 = NULL; *data_ptr_bytes_2 = 0; @@ -361,7 +361,7 @@ size_t WebRtc_ReadBuffer(void* handle, // We have a wrap around when reading the buffer. Copy the buffer data to // |data| and point to it. memcpy(data, buf_ptr_1, buf_ptr_bytes_1); - memcpy(data + buf_ptr_bytes_1, buf_ptr_2, buf_ptr_bytes_2); + memcpy(((char*) data) + buf_ptr_bytes_1, buf_ptr_2, buf_ptr_bytes_2); *data_ptr = data; } else { *data_ptr = buf_ptr_1; @@ -396,14 +396,14 @@ size_t WebRtc_WriteBuffer(void* handle, if (write_elements > margin) { // Buffer wrap around when writing. - memcpy(self->data + (self->write_pos * self->element_size), + memcpy(((char*) self->data) + (self->write_pos * self->element_size), data, margin * self->element_size); self->write_pos = 0; n -= margin; self->rw_wrap = DIFF_WRAP; } - memcpy(self->data + (self->write_pos * self->element_size), - data + ((write_elements - n) * self->element_size), + memcpy(((char*) self->data) + (self->write_pos * self->element_size), + ((const char*) data) + ((write_elements - n) * self->element_size), n * self->element_size); self->write_pos += n;