~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/memory/hp_open.cc

  • Committer: Stewart Smith
  • Date: 2010-11-03 03:27:09 UTC
  • mto: (1902.1.1 build) (1910.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 1903.
  • Revision ID: stewart@flamingspork.com-20101103032709-oyvfrc6eb8fzj0mr
fix docs warning: docs/unlock.rst:2: (WARNING/2) Title underline too short.

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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
14
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
15
15
 
16
16
/* open a heap-database */
17
17
 
31
31
 
32
32
HP_INFO *heap_open_from_share(HP_SHARE *share, int mode)
33
33
{
34
 
  HP_INFO *info;
 
34
  HP_INFO *info= new HP_INFO;
35
35
 
36
 
  if (!(info= (HP_INFO*) malloc(sizeof(HP_INFO) + 2 * share->max_key_length)))
37
 
  {
38
 
    return(0);
39
 
  }
40
 
  memset(info, 0, sizeof(HP_INFO) + 2 * share->max_key_length);
41
36
  share->open_count++;
42
 
  thr_lock_data_init(&share->lock,&info->lock,NULL);
43
 
  info->s= share;
44
 
  info->lastkey= (unsigned char*) (info + 1);
45
 
  info->recbuf= (unsigned char*) (info->lastkey + share->max_key_length);
 
37
  info->setShare(share);
 
38
  info->lastkey.resize(share->max_key_length);
46
39
  info->mode= mode;
47
40
  info->current_record= UINT32_MAX;             /* No current record */
48
41
  info->lastinx= info->errkey= -1;
49
 
  return(info);
 
42
  return info;
50
43
}
51
44
 
52
45
 
58
51
{
59
52
  HP_INFO *info;
60
53
 
61
 
  pthread_mutex_lock(&THR_LOCK_heap);
 
54
  THR_LOCK_heap.lock();
62
55
  if ((info= heap_open_from_share(share, mode)))
63
56
  {
64
57
    heap_open_list.push_front(info);
65
58
  }
66
 
  pthread_mutex_unlock(&THR_LOCK_heap);
 
59
  THR_LOCK_heap.unlock();
67
60
  return(info);
68
61
}
69
62
 
81
74
  HP_INFO *info;
82
75
  HP_SHARE *share;
83
76
 
84
 
  pthread_mutex_lock(&THR_LOCK_heap);
 
77
  THR_LOCK_heap.lock();
85
78
  if (!(share= hp_find_named_heap(name)))
86
79
  {
87
80
    errno= ENOENT;
88
 
    pthread_mutex_unlock(&THR_LOCK_heap);
 
81
    THR_LOCK_heap.unlock();
89
82
    return(0);
90
83
  }
91
84
  if ((info= heap_open_from_share(share, mode)))
92
85
  {
93
86
    heap_open_list.push_front(info);
94
87
  }
95
 
  pthread_mutex_unlock(&THR_LOCK_heap);
 
88
  THR_LOCK_heap.unlock();
96
89
  return(info);
97
90
}
98
91
 
104
97
  list<HP_SHARE *>::iterator it= heap_share_list.begin();
105
98
  while (it != heap_share_list.end())
106
99
  {
107
 
    if (!strcmp(name, (*it)->name))
 
100
    if (not (*it)->name.compare(name))
108
101
    {
109
102
      return (*it);
110
103
    }