diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2017-10-04 08:24:06 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2017-10-04 08:24:06 +0300 |
commit | 2c1067166d7e8a9541578220b408f1e553e23916 (patch) | |
tree | 2ba0932f92d88e01d51393de63dda842f6daf320 /sql/sql_string.h | |
parent | 2cf3e2ea2fca3d3613309de94d55c88dedb3831a (diff) | |
parent | 61b2618d3aae78950f1b8dbe8d4482573c77875d (diff) | |
download | mariadb-git-2c1067166d7e8a9541578220b408f1e553e23916.tar.gz |
Merge bb-10.2-ext into 10.3
Diffstat (limited to 'sql/sql_string.h')
-rw-r--r-- | sql/sql_string.h | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/sql/sql_string.h b/sql/sql_string.h index af3765443c5..c88c58b1b40 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -357,22 +357,22 @@ public: Ptr=0; str_length=0; /* Safety */ } - inline bool alloc(uint32 arg_length) + inline bool alloc(size_t arg_length) { if (arg_length < Alloced_length) return 0; return real_alloc(arg_length); } - bool real_alloc(uint32 arg_length); // Empties old string - bool realloc_raw(uint32 arg_length); - bool realloc(uint32 arg_length) + bool real_alloc(size_t arg_length); // Empties old string + bool realloc_raw(size_t arg_length); + bool realloc(size_t arg_length) { if (realloc_raw(arg_length)) return TRUE; Ptr[arg_length]=0; // This make other funcs shorter return FALSE; } - bool realloc_with_extra(uint32 arg_length) + bool realloc_with_extra(size_t arg_length) { if (extra_alloc < 4096) extra_alloc= extra_alloc*2+128; @@ -381,7 +381,7 @@ public: Ptr[arg_length]=0; // This make other funcs shorter return FALSE; } - bool realloc_with_extra_if_needed(uint32 arg_length) + bool realloc_with_extra_if_needed(size_t arg_length) { if (arg_length < Alloced_length) { @@ -391,7 +391,7 @@ public: return realloc_with_extra(arg_length); } // Shrink the buffer, but only if it is allocated on the heap. - inline void shrink(uint32 arg_length) + inline void shrink(size_t arg_length) { if (!is_alloced()) return; @@ -408,7 +408,7 @@ public: else { Ptr=new_ptr; - Alloced_length=arg_length; + Alloced_length=(uint32)arg_length; } } } @@ -431,7 +431,7 @@ public: bool copy(); // Alloc string if not alloced bool copy(const String &s); // Allocate new string - bool copy(const char *s,uint32 arg_length, CHARSET_INFO *cs); // Allocate new string + bool copy(const char *s,size_t arg_length, CHARSET_INFO *cs); // Allocate new string static bool needs_conversion(uint32 arg_length, CHARSET_INFO *cs_from, CHARSET_INFO *cs_to, uint32 *offset); @@ -484,8 +484,8 @@ public: DBUG_ASSERT(ls.length < UINT_MAX32); return append(ls.str, (uint32) ls.length); } - bool append(const char *s, uint32 arg_length); - bool append(const char *s, uint32 arg_length, CHARSET_INFO *cs); + bool append(const char *s, size_t size); + bool append(const char *s, uint arg_length, CHARSET_INFO *cs); bool append_ulonglong(ulonglong val); bool append_longlong(longlong val); bool append(IO_CACHE* file, uint32 arg_length); @@ -568,10 +568,11 @@ public: float8store(Ptr + str_length, *d); str_length += 8; } - void q_append(const char *data, uint32 data_len) + void q_append(const char *data, size_t data_len) { memcpy(Ptr + str_length, data, data_len); - str_length += data_len; + DBUG_ASSERT(str_length <= UINT_MAX32 - data_len); + str_length += (uint)data_len; } void q_append(const LEX_CSTRING *ls) { |