~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/hex_functions/hex_functions.cc

  • Committer: Monty Taylor
  • Date: 2011-02-13 17:26:39 UTC
  • mfrom: (2157.2.2 give-in-to-pkg-config)
  • mto: This revision was merged to the branch mainline in revision 2166.
  • Revision ID: mordred@inaugust.com-20110213172639-nhy7i72sfhoq13ms
Merged in pkg-config fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include <config.h>
 
20
#include "config.h"
21
21
 
22
 
#include <drizzled/charset.h>
 
22
#include <drizzled/charset_info.h>
23
23
#include <drizzled/function/str/strfunc.h>
24
24
#include <drizzled/internal/m_string.h>
25
25
#include <drizzled/plugin/function.h>
102
102
    if ((null_value= args[0]->null_value))
103
103
      return 0;
104
104
    ptr= internal::int64_t2str(dec,ans,16);
105
 
    str->copy(ans,(uint32_t) (ptr-ans),default_charset());
 
105
    if (str->copy(ans,(uint32_t) (ptr-ans),default_charset()))
 
106
      return &my_empty_string;                  // End of memory
106
107
    return str;
107
108
  }
108
109
 
109
110
  /* Convert given string to a hex string, character by character */
110
111
  res= args[0]->val_str(str);
111
 
  if (!res)
 
112
  if (!res || tmp_value.alloc(res->length()*2+1))
112
113
  {
113
114
    null_value=1;
114
115
    return 0;
115
116
  }
116
117
  null_value=0;
117
 
  tmp_value.alloc(res->length()*2+1);
118
118
  tmp_value.length(res->length()*2);
119
119
 
120
120
  (void) drizzled_string_to_hex((char*) tmp_value.ptr(), res->ptr(),
133
133
  assert(fixed == 1);
134
134
 
135
135
  res= args[0]->val_str(str);
136
 
  if (!res)
 
136
  if (!res || tmp_value.alloc(length= (1+res->length())/2))
137
137
  {
138
138
    null_value=1;
139
139
    return 0;
140
140
  }
141
 
  tmp_value.alloc(length= (1+res->length())/2);
142
141
 
143
142
  from= res->ptr();
144
143
  null_value= 0;