diff options
author | unknown <bar@bar.mysql.r18.ru> | 2002-11-10 14:05:17 +0400 |
---|---|---|
committer | unknown <bar@bar.mysql.r18.ru> | 2002-11-10 14:05:17 +0400 |
commit | 74985d1353ac1acf478047c8c8393b4323850342 (patch) | |
tree | 913578f8497239471741e9f5b419df4526f5c6b7 /client/sql_string.h | |
parent | 2d0dedbbf696dac721a2583ad3f5589f6e7ce329 (diff) | |
download | mariadb-git-74985d1353ac1acf478047c8c8393b4323850342.tar.gz |
Fixes for fault about String::copy()
Diffstat (limited to 'client/sql_string.h')
-rw-r--r-- | client/sql_string.h | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/client/sql_string.h b/client/sql_string.h index 811e49a0d02..4ac4308f113 100644 --- a/client/sql_string.h +++ b/client/sql_string.h @@ -46,22 +46,22 @@ public: String(uint32 length_arg) { alloced=0; Alloced_length=0; (void) real_alloc(length_arg); - str_charset=default_charset_info; + str_charset=default_charset_info; } - String(const char *str) + String(const char *str, CHARSET_INFO *cs) { Ptr=(char*) str; str_length=(uint) strlen(str); Alloced_length=0; alloced=0; - str_charset=default_charset_info; + str_charset=cs; } - String(const char *str,uint32 len) + String(const char *str,uint32 len, CHARSET_INFO *cs) { Ptr=(char*) str; str_length=len; Alloced_length=0; alloced=0; - str_charset=default_charset_info; + str_charset=cs; } - String(char *str,uint32 len) + String(char *str,uint32 len, CHARSET_INFO *cs) { Ptr=(char*) str; Alloced_length=str_length=len; alloced=0; - str_charset=default_charset_info; + str_charset=cs; } String(const String &str) { @@ -74,6 +74,7 @@ public: { sql_element_free(ptr_arg); } ~String() { free(); } + inline void set_charset(CHARSET_INFO *charset) { str_charset=charset; } inline CHARSET_INFO *charset() const { return str_charset; } inline uint32 length() const { return str_length;} inline uint32 alloced_length() const { return Alloced_length;} @@ -102,28 +103,31 @@ public: Alloced_length=str.Alloced_length-offset; else Alloced_length=0; + str_charset=str.str_charset; } - inline void set(char *str,uint32 arg_length) + inline void set(char *str,uint32 arg_length, CHARSET_INFO *cs) { free(); Ptr=(char*) str; str_length=Alloced_length=arg_length ; alloced=0; + str_charset=cs; } - inline void set(const char *str,uint32 arg_length) + inline void set(const char *str,uint32 arg_length, CHARSET_INFO *cs) { free(); Ptr=(char*) str; str_length=arg_length; Alloced_length=0 ; alloced=0; + str_charset=cs; } - inline void set_quick(char *str,uint32 arg_length) + inline void set_quick(char *str,uint32 arg_length, CHARSET_INFO *cs) { if (!alloced) { Ptr=(char*) str; str_length=Alloced_length=arg_length; } + str_charset=cs; } - bool set(longlong num); - /* bool set(long num); */ - bool set(ulonglong num); - bool set(double num,uint decimals=2); + bool set(longlong num, CHARSET_INFO *cs); + bool set(ulonglong num, CHARSET_INFO *cs); + bool set(double num,uint decimals, CHARSET_INFO *cs); inline void free() { if (alloced) @@ -174,7 +178,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); // Allocate new string + bool copy(const char *s,uint32 arg_length, CHARSET_INFO *cs); // Allocate new string bool append(const String &s); bool append(const char *s,uint32 arg_length=0); bool append(IO_CACHE* file, uint32 arg_length); @@ -208,16 +212,17 @@ public: uint32 numchars(); int charpos(int i,uint32 offset=0); -// added by Holyfoot for "geometry" needs int reserve(uint32 space_needed) { return realloc(str_length + space_needed); } int reserve(uint32 space_needed, uint32 grow_by); -// these append operations do NOT check alloced memory -// q_*** methods writes values of parameters itself -// qs_*** methods writes string representation of value + /* + The following append operations do NOT check alloced memory + q_*** methods writes values of parameters itself + qs_*** methods writes string representation of value + */ void q_append(const char &c) { Ptr[str_length++] = c; |