summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJosh Blum2012-11-19 19:42:14 -0800
committerJosh Blum2012-11-19 19:42:14 -0800
commit1018a24939885ca6eff6e0bf3977bbef18ae973f (patch)
treecceba77520696a004068fe96ee5e961a2e40083c /include
parent216b8685e7889698567cd47e8f93ec672a2e5323 (diff)
downloadsandhi-1018a24939885ca6eff6e0bf3977bbef18ae973f.tar.gz
sandhi-1018a24939885ca6eff6e0bf3977bbef18ae973f.tar.bz2
sandhi-1018a24939885ca6eff6e0bf3977bbef18ae973f.zip
const correctness for sbuffer get()
Diffstat (limited to 'include')
-rw-r--r--include/gras/sbuffer.hpp12
-rw-r--r--include/gras/sbuffer.ipp14
2 files changed, 22 insertions, 4 deletions
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<SBufferImpl>
/*!
* 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<SBufferImpl>
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;
}