~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_list.cc

  • Committer: Brian Aker
  • Date: 2010-02-10 18:04:24 UTC
  • mfrom: (1286.1.5 build)
  • Revision ID: brian@gaz-20100210180424-03ypoyifmlc2lgcp
Merge of Brian/Padraig

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
16
 
17
 
#include <drizzled/server_includes.h>
 
17
#include "config.h"
 
18
 
 
19
#include "drizzled/sql_list.h"
 
20
 
 
21
namespace drizzled
 
22
{
18
23
 
19
24
list_node end_of_list;
20
25
 
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
 
}
 
26
} /* namespace drizzled */