Commit e238d6c5 authored by Sergei Golubchik's avatar Sergei Golubchik

String::release and String::reset methods

Rename reassociate to reset and create an inverse method release.
Method names are chosen to match std::unique_ptr methods.
parent 4569a895
......@@ -4583,8 +4583,7 @@ String *Item_func_dyncol_create::val_str(String *str)
char *ptr;
size_t length, alloc_length;
dynstr_reassociate(&col, &ptr, &length, &alloc_length);
str_value.reassociate(ptr, (uint32) length, (uint32) alloc_length,
&my_charset_bin);
str_value.reset(ptr, length, alloc_length, &my_charset_bin);
res= &str_value;
null_value= FALSE;
}
......@@ -4676,8 +4675,7 @@ String *Item_func_dyncol_json::val_str(String *str)
char *ptr;
size_t length, alloc_length;
dynstr_reassociate(&json, &ptr, &length, &alloc_length);
str->reassociate(ptr, (uint32) length, (uint32) alloc_length,
&my_charset_utf8_general_ci);
str->reset(ptr, length, alloc_length, &my_charset_utf8_general_ci);
null_value= FALSE;
}
return str;
......@@ -4725,8 +4723,7 @@ String *Item_func_dyncol_add::val_str(String *str)
char *ptr;
size_t length, alloc_length;
dynstr_reassociate(&col, &ptr, &length, &alloc_length);
str->reassociate(ptr, (uint32) length, (uint32) alloc_length,
&my_charset_bin);
str->reset(ptr, length, alloc_length, &my_charset_bin);
null_value= FALSE;
}
......
......@@ -257,9 +257,9 @@ class String
bool set(ulonglong num, CHARSET_INFO *cs) { return set_int((longlong)num, true, cs); }
bool set_real(double num,uint decimals, CHARSET_INFO *cs);
/* Move handling of buffer from some other object to String */
void reassociate(char *ptr_arg, uint32 length_arg, uint32 alloced_length_arg,
CHARSET_INFO *cs)
/* Take over handling of buffer from some other object */
void reset(char *ptr_arg, uint32 length_arg, uint32 alloced_length_arg,
CHARSET_INFO *cs)
{
free();
Ptr= ptr_arg;
......@@ -269,6 +269,15 @@ class String
alloced= ptr_arg != 0;
}
/* Forget about the buffer, let some other object handle it */
char *release()
{
char *old= Ptr;
Ptr=0; str_length= Alloced_length= extra_alloc= 0;
alloced= thread_specific= 0;
return old;
}
/*
PMG 2004.11.12
This is a method that works the same as perl's "chop". It simply
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment