~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/heap/hp_open.c

  • Committer: Brian Aker
  • Date: 2008-10-06 06:47:29 UTC
  • Revision ID: brian@tangent.org-20081006064729-2i9mhjkzyvow9xsm
Remove uint.

Show diffs side-by-side

added added

removed removed

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