From 1018a24939885ca6eff6e0bf3977bbef18ae973f Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 19 Nov 2012 19:42:14 -0800 Subject: const correctness for sbuffer get() --- include/gras/sbuffer.hpp | 12 ++++++++++-- include/gras/sbuffer.ipp | 14 ++++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/gras/sbuffer.hpp b/include/gras/sbuffer.hpp index bf60026..5761625 100644 --- a/include/gras/sbuffer.hpp +++ b/include/gras/sbuffer.hpp @@ -92,7 +92,12 @@ struct GRAS_API SBuffer : boost::intrusive_ptr /*! * Get a pointer to the start of the underlying memory */ - void *get_actual_memory(void) const; + const void *get_actual_memory(void) const; + + /*! + * Get a pointer to the start of the underlying memory + */ + void *get_actual_memory(void); /*! * Get the length of the underlying memory in bytes @@ -100,7 +105,10 @@ struct GRAS_API SBuffer : boost::intrusive_ptr size_t get_actual_length(void) const; //! Get a pointer into valid memory - void *get(const ptrdiff_t delta_bytes = 0) const; + const void *get(const ptrdiff_t delta_bytes = 0) const; + + //! Get a pointer into valid memory + void *get(const ptrdiff_t delta_bytes = 0); //! The offset into valid memory in bytes size_t offset; diff --git a/include/gras/sbuffer.ipp b/include/gras/sbuffer.ipp index 233b4ce..7db390d 100644 --- a/include/gras/sbuffer.ipp +++ b/include/gras/sbuffer.ipp @@ -44,7 +44,12 @@ GRAS_FORCE_INLINE SBuffer::SBuffer(void): //NOP } -GRAS_FORCE_INLINE void *SBuffer::get_actual_memory(void) const +GRAS_FORCE_INLINE const void *SBuffer::get_actual_memory(void) const +{ + return (*this)->config.memory; +} + +GRAS_FORCE_INLINE void *SBuffer::get_actual_memory(void) { return (*this)->config.memory; } @@ -54,7 +59,12 @@ GRAS_FORCE_INLINE size_t SBuffer::get_actual_length(void) const return (*this)->config.length; } -GRAS_FORCE_INLINE void *SBuffer::get(const ptrdiff_t delta_bytes) const +GRAS_FORCE_INLINE const void *SBuffer::get(const ptrdiff_t delta_bytes) const +{ + return ((char *)(*this)->config.memory) + this->offset + delta_bytes; +} + +GRAS_FORCE_INLINE void *SBuffer::get(const ptrdiff_t delta_bytes) { return ((char *)(*this)->config.memory) + this->offset + delta_bytes; } -- cgit