1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

yet another generalization for rec_buff handling, MI_INFO doesn't need rec_alloc anymore

myisam/mi_close.c:
  yet another generalization for rec_buff handling
myisam/mi_dynrec.c:
  yet another generalization for rec_buff handling
myisam/mi_extra.c:
  yet another generalization for rec_buff handling
myisam/mi_open.c:
  yet another generalization for rec_buff handling
myisam/myisamdef.h:
  yet another generalization for rec_buff handling
This commit is contained in:
unknown
2002-07-14 13:51:03 +02:00
parent 9a1ff13ea4
commit d8093cf6ff
5 changed files with 50 additions and 47 deletions

View File

@ -507,9 +507,9 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
/* Allocate buffer for one record */
/* prerequisites: bzero(info) && info->s=share; are met. */
if (!mi_fix_rec_buff_for_blob(&info, 0))
if (!mi_fix_rec_buff_for_blob(&info, -1))
goto err;
bzero(info.rec_alloc, info.alloced_rec_buff_length);
bzero(info.rec_buff, info.alloced_rec_buff_length);
*m_info=info;
#ifdef THREAD
@ -559,6 +559,39 @@ err:
DBUG_RETURN (NULL);
} /* mi_open */
gptr mi_get_rec_buff_ptr(MI_INFO *info, byte *buf)
{
if (info->s->options & HA_OPTION_PACK_RECORD && buf)
return buf - MI_REC_BUFF_OFFSET;
else
return buf;
}
byte *mi_alloc_rec_buff(MI_INFO *info, ulong length, byte **buf, uint *buf_len)
{
uint extra;
if (! *buf || length > *buf_len)
{
byte *newptr = *buf;
/* to simplify initial init of info->rec_buf in mi_open and mi_extra */
if (length == (ulong)-1)
length=max(info->s->base.pack_reclength,info->s->base.max_key_length);
extra= ((info->s->options & HA_OPTION_PACK_RECORD) ?
ALIGN_SIZE(MI_MAX_DYN_BLOCK_HEADER)+MI_SPLIT_LENGTH+
MI_REC_BUFF_OFFSET : 0);
if (extra && newptr)
newptr-=MI_REC_BUFF_OFFSET;
if (!(newptr=(byte*) my_realloc((gptr)newptr, length+extra+8,
MYF(MY_ALLOW_ZERO_PTR))))
return 0;
*buf=newptr+(extra ? MI_REC_BUFF_OFFSET : 0);
*buf_len=length;
}
return *buf;
}
ulonglong mi_safe_mul(ulonglong a, ulonglong b)
{