~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_list.cc

  • Committer: Brian Aker
  • Date: 2009-02-21 00:18:15 UTC
  • Revision ID: brian@tangent.org-20090221001815-x20e8h71e984lvs1
Completion (?) of uint conversion.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
   You should have received a copy of the GNU General Public License
13
13
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
15
 
 
16
 
 
17
 
#include "config.h"
18
 
 
19
 
#include "drizzled/sql_list.h"
20
 
 
21
 
namespace drizzled
22
 
{
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
 
 
16
 
 
17
#include <drizzled/server_includes.h>
23
18
 
24
19
list_node end_of_list;
25
20
 
26
 
} /* namespace drizzled */
 
21
void free_list(I_List <i_string_pair> *list)
 
22
{
 
23
  i_string_pair *tmp;
 
24
  while ((tmp= list->get()))
 
25
    delete tmp;
 
26
}
 
27
 
 
28
 
 
29
void free_list(I_List <i_string> *list)
 
30
{
 
31
  i_string *tmp;
 
32
  while ((tmp= list->get()))
 
33
    delete tmp;
 
34
}
 
35
 
 
36
 
 
37
base_list::base_list(const base_list &rhs, MEM_ROOT *mem_root)
 
38
{
 
39
  if (rhs.elements)
 
40
  {
 
41
    /*
 
42
      It's okay to allocate an array of nodes at once: we never
 
43
      call a destructor for list_node objects anyway.
 
44
    */
 
45
    first= (list_node*) alloc_root(mem_root,
 
46
                                   sizeof(list_node) * rhs.elements);
 
47
    if (first)
 
48
    {
 
49
      elements= rhs.elements;
 
50
      list_node *dst= first;
 
51
      list_node *src= rhs.first;
 
52
      for (; dst < first + elements - 1; dst++, src= src->next)
 
53
      {
 
54
        dst->info= src->info;
 
55
        dst->next= dst + 1;
 
56
      }
 
57
      /* Copy the last node */
 
58
      dst->info= src->info;
 
59
      dst->next= &end_of_list;
 
60
      /* Setup 'last' member */
 
61
      last= &dst->next;
 
62
      return;
 
63
    }
 
64
  }
 
65
  elements= 0;
 
66
  first= &end_of_list;
 
67
  last= &first;
 
68
}