~ubuntu-branches/ubuntu/maverick/mysql-5.1/maverick-proposed

« back to all changes in this revision

Viewing changes to sql/sql_string.h

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-22 14:16:05 UTC
  • mto: This revision was merged to the branch mainline in revision 20.
  • Revision ID: package-import@ubuntu.com-20120222141605-nxlu9yzc6attylc2
Tags: upstream-5.1.61
ImportĀ upstreamĀ versionĀ 5.1.61

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2000 MySQL AB
 
1
/*
 
2
   Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
2
3
 
3
4
   This program is free software; you can redistribute it and/or modify
4
5
   it under the terms of the GNU General Public License as published by
11
12
 
12
13
   You should have received a copy of the GNU General Public License
13
14
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
 
16
*/
15
17
 
16
18
/* This file is originally from the mysql distribution. Coded by monty */
17
19
 
84
86
  }
85
87
  static void *operator new(size_t size, MEM_ROOT *mem_root) throw ()
86
88
  { return (void*) alloc_root(mem_root, (uint) size); }
87
 
  static void operator delete(void *ptr_arg,size_t size)
88
 
  { TRASH(ptr_arg, size); }
89
 
  static void operator delete(void *ptr_arg, MEM_ROOT *mem_root)
 
89
  static void operator delete(void *ptr_arg, size_t size)
 
90
  {
 
91
    (void) ptr_arg;
 
92
    (void) size;
 
93
    TRASH(ptr_arg, size);
 
94
  }
 
95
  static void operator delete(void *, MEM_ROOT *)
90
96
  { /* never called */ }
91
97
  ~String() { free(); }
92
98
 
97
103
  inline uint32 alloced_length() const { return Alloced_length;}
98
104
  inline char& operator [] (uint32 i) const { return Ptr[i]; }
99
105
  inline void length(uint32 len) { str_length=len ; }
100
 
  inline bool is_empty() { return (str_length == 0); }
 
106
  inline bool is_empty() const { return (str_length == 0); }
101
107
  inline void mark_as_const() { Alloced_length= 0;}
102
108
  inline const char *ptr() const { return Ptr; }
103
109
  inline char *c_ptr()
104
110
  {
 
111
    DBUG_ASSERT(!alloced || !Ptr || !Alloced_length || 
 
112
                (Alloced_length >= (str_length + 1)));
 
113
 
105
114
    if (!Ptr || Ptr[str_length])                /* Should be safe */
106
115
      (void) realloc(str_length);
107
116
    return Ptr;
132
141
      Alloced_length=0;
133
142
    str_charset=str.str_charset;
134
143
  }
 
144
 
 
145
 
 
146
  /**
 
147
     Points the internal buffer to the supplied one. The old buffer is freed.
 
148
     @param str Pointer to the new buffer.
 
149
     @param arg_length Length of the new buffer in characters, excluding any 
 
150
            null character.
 
151
     @param cs Character set to use for interpreting string data.
 
152
     @note The new buffer will not be null terminated.
 
153
  */
135
154
  inline void set(char *str,uint32 arg_length, CHARSET_INFO *cs)
136
155
  {
137
156
    free();