~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/archive/ha_archive.cc

Slip to  vector for record buffer.

Show diffs side-by-side

added added

removed removed

Lines of Context:
472
472
 
473
473
  assert(share);
474
474
 
475
 
  record_buffer= create_record_buffer(table->getShare()->getRecordLength() +
476
 
                                      ARCHIVE_ROW_HEADER_SIZE);
477
 
 
478
 
  if (!record_buffer)
479
 
  {
480
 
    free_share();
481
 
    return(HA_ERR_OUT_OF_MEM);
482
 
  }
 
475
  record_buffer.resize(table->getShare()->getRecordLength() + ARCHIVE_ROW_HEADER_SIZE);
483
476
 
484
477
  thr_lock_data_init(&share->lock, &lock);
485
478
 
515
508
{
516
509
  int rc= 0;
517
510
 
518
 
  destroy_record_buffer(record_buffer);
 
511
  record_buffer.clear();
519
512
 
520
513
  /* First close stream */
521
514
  if (archive_reader_open == true)
647
640
  /* We pack the row for writing */
648
641
  r_pack_length= pack_row(buf);
649
642
 
650
 
  written= azwrite_row(writer, record_buffer->buffer, r_pack_length);
 
643
  written= azwrite_row(writer, &record_buffer[0], r_pack_length);
651
644
  if (written != r_pack_length)
652
645
  {
653
646
    return(-1);
690
683
    return(HA_ERR_OUT_OF_MEM);
691
684
 
692
685
  /* Copy null bits */
693
 
  memcpy(record_buffer->buffer, record, table->getShare()->null_bytes);
694
 
  ptr= record_buffer->buffer + table->getShare()->null_bytes;
 
686
  memcpy(&record_buffer[0], record, table->getShare()->null_bytes);
 
687
  ptr= &record_buffer[0] + table->getShare()->null_bytes;
695
688
 
696
689
  for (Field **field=table->getFields() ; *field ; field++)
697
690
  {
699
692
      ptr= (*field)->pack(ptr, record + (*field)->offset(record));
700
693
  }
701
694
 
702
 
  return((unsigned int) (ptr - record_buffer->buffer));
 
695
  return((unsigned int) (ptr - &record_buffer[0]));
703
696
}
704
697
 
705
698
 
876
869
/* Reallocate buffer if needed */
877
870
bool ha_archive::fix_rec_buff(unsigned int length)
878
871
{
879
 
  assert(record_buffer->buffer);
880
 
 
881
 
  if (length > record_buffer->length)
882
 
  {
883
 
    unsigned char *newptr;
884
 
    if (!(newptr= (unsigned char *)realloc(record_buffer->buffer, length)))
885
 
      return(1);
886
 
    record_buffer->buffer= newptr;
887
 
    record_buffer->length= length;
888
 
  }
889
 
 
890
 
  assert(length <= record_buffer->length);
891
 
 
892
 
  return(0);
 
872
  record_buffer.resize(length);
 
873
 
 
874
  return false;
893
875
}
894
876
 
895
877
int ha_archive::unpack_row(azio_stream *file_to_read, unsigned char *record)
1305
1287
  }
1306
1288
}
1307
1289
 
1308
 
archive_record_buffer *ha_archive::create_record_buffer(unsigned int length)
1309
 
{
1310
 
  archive_record_buffer *r;
1311
 
  if (!(r= (archive_record_buffer*) malloc(sizeof(archive_record_buffer))))
1312
 
  {
1313
 
    return(NULL);
1314
 
  }
1315
 
  r->length= (int)length;
1316
 
 
1317
 
  if (!(r->buffer= (unsigned char*) malloc(r->length)))
1318
 
  {
1319
 
    free((char*) r);
1320
 
    return(NULL);
1321
 
  }
1322
 
 
1323
 
  return(r);
1324
 
}
1325
 
 
1326
 
void ha_archive::destroy_record_buffer(archive_record_buffer *r)
1327
 
{
1328
 
  free((char*) r->buffer);
1329
 
  free((char*) r);
1330
 
  return;
1331
 
}
1332
 
 
1333
1290
int ArchiveEngine::doRenameTable(Session&, const TableIdentifier &from, const TableIdentifier &to)
1334
1291
{
1335
1292
  int error= 0;