mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Fixes for fault about String::copy()
This commit is contained in:
@ -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;
|
||||
|
Reference in New Issue
Block a user