~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/heap/hp_open.cc

Finished first pass at Protocol cleanup, still some things to remove but they are a bit more involved.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
/* open a heap-database */
17
17
 
18
18
#include "heapdef.h"
19
 
#ifdef VMS
20
 
#include "hp_static.c"                  /* Stupid vms-linker */
21
 
#endif
22
 
 
23
 
#include <mysys/my_sys.h>
 
19
 
 
20
#include <string.h>
 
21
 
 
22
using namespace std;
24
23
 
25
24
/*
26
25
  Open heap table based on HP_SHARE structure
27
 
  
 
26
 
28
27
  NOTE
29
28
    This doesn't register the table in the open table list.
30
29
*/
33
32
{
34
33
  HP_INFO *info;
35
34
 
36
 
  if (!(info= (HP_INFO*) my_malloc((uint) sizeof(HP_INFO) +
37
 
                                  2 * share->max_key_length,
38
 
                                  MYF(MY_ZEROFILL))))
 
35
  if (!(info= (HP_INFO*) malloc(sizeof(HP_INFO) + 2 * share->max_key_length)))
39
36
  {
40
37
    return(0);
41
38
  }
42
 
  share->open_count++; 
 
39
  memset(info, 0, sizeof(HP_INFO) + 2 * share->max_key_length);
 
40
  share->open_count++;
43
41
  thr_lock_data_init(&share->lock,&info->lock,NULL);
44
42
  info->s= share;
45
43
  info->lastkey= (unsigned char*) (info + 1);
62
60
  pthread_mutex_lock(&THR_LOCK_heap);
63
61
  if ((info= heap_open_from_share(share, mode)))
64
62
  {
65
 
    info->open_list.data= (void*) info;
66
 
    heap_open_list= list_add(heap_open_list,&info->open_list);
 
63
    heap_open_list.push_front(info);
67
64
  }
68
65
  pthread_mutex_unlock(&THR_LOCK_heap);
69
66
  return(info);
92
89
  }
93
90
  if ((info= heap_open_from_share(share, mode)))
94
91
  {
95
 
    info->open_list.data= (void*) info;
96
 
    heap_open_list= list_add(heap_open_list,&info->open_list);
 
92
    heap_open_list.push_front(info);
97
93
  }
98
94
  pthread_mutex_unlock(&THR_LOCK_heap);
99
95
  return(info);
104
100
 
105
101
HP_SHARE *hp_find_named_heap(const char *name)
106
102
{
107
 
  LIST *pos;
108
 
  HP_SHARE *info;
109
 
 
110
 
  for (pos= heap_share_list; pos; pos= pos->next)
 
103
  list<HP_SHARE *>::iterator it= heap_share_list.begin();
 
104
  while (it != heap_share_list.end())
111
105
  {
112
 
    info= (HP_SHARE*) pos->data;
113
 
    if (!strcmp(name, info->name))
 
106
    if (!strcmp(name, (*it)->name))
114
107
    {
115
 
      return(info);
 
108
      return (*it);
116
109
    }
 
110
    ++it;
117
111
  }
118
112
  return((HP_SHARE *) 0);
119
113
}