~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/heap/hp_rfirst.c

Cleanup around SAFEMALLOC

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
   along with this program; if not, write to the Free Software
14
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
 
#include "heap_priv.h"
17
 
 
18
 
#include <string.h>
19
 
#include <cassert>
20
 
 
21
 
using namespace drizzled;
 
16
#include "heapdef.h"
22
17
 
23
18
/* Read first record with the current key */
24
19
 
25
 
int heap_rfirst(HP_INFO *info, unsigned char *record, int inx)
 
20
int heap_rfirst(HP_INFO *info, uchar *record, int inx)
26
21
{
27
22
  HP_SHARE *share = info->s;
28
23
  HP_KEYDEF *keyinfo = share->keydef + inx;
29
 
 
 
24
  
30
25
  info->lastinx= inx;
31
26
  if (keyinfo->algorithm == HA_KEY_ALG_BTREE)
32
27
  {
33
 
    unsigned char *pos;
 
28
    uchar *pos;
34
29
 
35
 
    if ((pos = (unsigned char *)tree_search_edge(&keyinfo->rb_tree,
36
 
                                                 info->parents,
37
 
                                                 &info->last_pos,
38
 
                                                 offsetof(TREE_ELEMENT, left))))
 
30
    if ((pos = tree_search_edge(&keyinfo->rb_tree, info->parents,
 
31
                                &info->last_pos, offsetof(TREE_ELEMENT, left))))
39
32
    {
40
 
      memcpy(&pos, pos + (*keyinfo->get_key_length)(keyinfo, pos),
41
 
             sizeof(unsigned char*));
 
33
      memcpy(&pos, pos + (*keyinfo->get_key_length)(keyinfo, pos), 
 
34
             sizeof(uchar*));
42
35
      info->current_ptr = pos;
43
36
      hp_extract_record(share, record, pos);
44
37
      /*
56
49
    }
57
50
    else
58
51
    {
59
 
      errno = HA_ERR_END_OF_FILE;
60
 
      return(errno);
 
52
      my_errno = HA_ERR_END_OF_FILE;
 
53
      return(my_errno);
61
54
    }
62
55
    return(0);
63
56
  }
65
58
  {
66
59
    if (!(info->s->records))
67
60
    {
68
 
      errno=HA_ERR_END_OF_FILE;
69
 
      return(errno);
 
61
      my_errno=HA_ERR_END_OF_FILE;
 
62
      return(my_errno);
70
63
    }
71
64
    assert(0); /* TODO fix it */
72
65
    info->current_record=0;