00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "heap_priv.h"
00019
00020 #include <string.h>
00021 #include <cstdlib>
00022
00023 using namespace std;
00024
00025
00026
00027
00028
00029
00030
00031
00032 HP_INFO *heap_open_from_share(HP_SHARE *share, int mode)
00033 {
00034 HP_INFO *info= new HP_INFO;
00035
00036 share->open_count++;
00037 info->setShare(share);
00038 info->lastkey.resize(share->max_key_length);
00039 info->mode= mode;
00040 info->current_record= UINT32_MAX;
00041 info->lastinx= info->errkey= -1;
00042 return info;
00043 }
00044
00045
00046
00047
00048
00049
00050 HP_INFO *heap_open_from_share_and_register(HP_SHARE *share, int mode)
00051 {
00052 HP_INFO *info;
00053
00054 THR_LOCK_heap.lock();
00055 if ((info= heap_open_from_share(share, mode)))
00056 {
00057 heap_open_list.push_front(info);
00058 }
00059 THR_LOCK_heap.unlock();
00060 return(info);
00061 }
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072 HP_INFO *heap_open(const char *name, int mode)
00073 {
00074 HP_INFO *info;
00075 HP_SHARE *share;
00076
00077 THR_LOCK_heap.lock();
00078 if (!(share= hp_find_named_heap(name)))
00079 {
00080 errno= ENOENT;
00081 THR_LOCK_heap.unlock();
00082 return(0);
00083 }
00084 if ((info= heap_open_from_share(share, mode)))
00085 {
00086 heap_open_list.push_front(info);
00087 }
00088 THR_LOCK_heap.unlock();
00089 return(info);
00090 }
00091
00092
00093
00094
00095 HP_SHARE *hp_find_named_heap(const char *name)
00096 {
00097 list<HP_SHARE *>::iterator it= heap_share_list.begin();
00098 while (it != heap_share_list.end())
00099 {
00100 if (not (*it)->name.compare(name))
00101 {
00102 return (*it);
00103 }
00104 ++it;
00105 }
00106 return((HP_SHARE *) 0);
00107 }
00108
00109