diff options
author | Sergei Golubchik <serg@mariadb.org> | 2016-10-18 10:17:55 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2016-12-12 20:27:33 +0100 |
commit | 65e53c8bc6727c4d5909864052d4c6e6c967e870 (patch) | |
tree | 31121dbf47443cd9c21ffaffa6a4c55d0487c033 /sql/field.h | |
parent | 9a3ec79b53ea1916211b4134375ebde5fb7c914c (diff) | |
download | mariadb-git-65e53c8bc6727c4d5909864052d4c6e6c967e870.tar.gz |
cleanup: Field_blob::get_ptr()
and declare few other Field getters to be 'const'
Diffstat (limited to 'sql/field.h')
-rw-r--r-- | sql/field.h | 46 |
1 files changed, 22 insertions, 24 deletions
diff --git a/sql/field.h b/sql/field.h index 52e0d2ea6d7..4292f3ffc8a 100644 --- a/sql/field.h +++ b/sql/field.h @@ -1265,7 +1265,7 @@ public: virtual uint max_packed_col_length(uint max_length) { return max_length;} - uint offset(uchar *record) + uint offset(uchar *record) const { return (uint) (ptr - record); } @@ -3266,30 +3266,29 @@ public: { store_length(ptr, packlength, number); } - inline uint32 get_length(uint row_offset= 0) + inline uint32 get_length(uint row_offset= 0) const { return get_length(ptr+row_offset, this->packlength); } - uint32 get_length(const uchar *ptr, uint packlength); - uint32 get_length(const uchar *ptr_arg) + uint32 get_length(const uchar *ptr, uint packlength) const; + uint32 get_length(const uchar *ptr_arg) const { return get_length(ptr_arg, this->packlength); } - inline void get_ptr(uchar **str) - { - memcpy(str, ptr+packlength, sizeof(uchar*)); - } - inline void get_ptr(uchar **str, uint row_offset) - { - memcpy(str, ptr+packlength+row_offset, sizeof(char*)); - } + inline uchar *get_ptr() const { return get_ptr(0); } + inline uchar *get_ptr(my_ptrdiff_t row_offset) const + { + uchar *s; + memcpy(&s, ptr + packlength + row_offset, sizeof(uchar*)); + return s; + } inline void set_ptr(uchar *length, uchar *data) - { - memcpy(ptr,length,packlength); - memcpy(ptr+packlength, &data,sizeof(char*)); - } + { + memcpy(ptr,length,packlength); + memcpy(ptr+packlength, &data,sizeof(char*)); + } void set_ptr_offset(my_ptrdiff_t ptr_diff, uint32 length, uchar *data) - { - uchar *ptr_ofs= ADD_TO_PTR(ptr,ptr_diff,uchar*); - store_length(ptr_ofs, packlength, length); - memcpy(ptr_ofs+packlength, &data, sizeof(char*)); - } + { + uchar *ptr_ofs= ADD_TO_PTR(ptr,ptr_diff,uchar*); + store_length(ptr_ofs, packlength, length); + memcpy(ptr_ofs+packlength, &data, sizeof(char*)); + } inline void set_ptr(uint32 length, uchar *data) { set_ptr_offset(0, length, data); @@ -3303,8 +3302,7 @@ public: void sql_type(String &str) const; inline bool copy() { - uchar *tmp; - get_ptr(&tmp); + uchar *tmp= get_ptr(); if (value.copy((char*) tmp, get_length(), charset())) { Field_blob::reset(); @@ -3320,7 +3318,7 @@ public: uint packed_col_length(const uchar *col_ptr, uint length); uint max_packed_col_length(uint max_length); void free() { value.free(); } - inline void clear_temporary() { bzero((uchar*) &value,sizeof(value)); } + inline void clear_temporary() { bzero((uchar*) &value, sizeof(value)); } uint size_of() const { return sizeof(*this); } bool has_charset(void) const { return charset() == &my_charset_bin ? FALSE : TRUE; } |