~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_load.cc

  • Committer: Monty Taylor
  • Date: 2009-05-24 23:54:21 UTC
  • mfrom: (1014.2.12 kill-malloc)
  • mto: This revision was merged to the branch mainline in revision 1039.
  • Revision ID: mordred@inaugust.com-20090524235421-x5vfss90auzbn896
Merged Monty from lp:~mordred/drizzle/kill-malloc

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
class READ_INFO {
28
28
  File  file;
29
 
  unsigned char *buffer,                        /* Buffer for read text */
30
 
        *end_of_buff;                   /* Data in bufferts ends here */
31
 
  uint  buff_length,                    /* Length of buffert */
32
 
        max_length;                     /* Max length of row */
 
29
  unsigned char *buffer;                /* Buffer for read text */
 
30
  unsigned char *end_of_buff;           /* Data in bufferts ends here */
 
31
  size_t buff_length;                   /* Length of buffert */
 
32
  size_t max_length;                    /* Max length of row */
33
33
  char  *field_term_ptr,*line_term_ptr,*line_start_ptr,*line_start_end;
34
34
  uint  field_term_length,line_term_length,enclosed_length;
35
35
  int   field_term_char,line_term_char,enclosed_char,escape_char;
44
44
        *row_end;                       /* Found row ends here */
45
45
  const CHARSET_INFO *read_charset;
46
46
 
47
 
  READ_INFO(File file,uint32_t tot_length, const CHARSET_INFO * const cs,
 
47
  READ_INFO(File file, size_t tot_length, const CHARSET_INFO * const cs,
48
48
            String &field_term,String &line_start,String &line_term,
49
49
            String &enclosed,int escape, bool is_fifo);
50
50
  ~READ_INFO();
203
203
 
204
204
  table->mark_columns_needed_for_insert();
205
205
 
206
 
  uint32_t tot_length=0;
 
206
  size_t tot_length=0;
207
207
  bool use_blobs= 0, use_vars= 0;
208
208
  List_iterator_fast<Item> it(fields_vars);
209
209
  Item *item;
465
465
        unsigned char save_chr;
466
466
        if ((length=(uint32_t) (read_info.row_end-pos)) >
467
467
            field->field_length)
 
468
        {
468
469
          length=field->field_length;
469
 
        save_chr=pos[length]; pos[length]='\0'; // Safeguard aganst malloc
 
470
        }
 
471
        save_chr=pos[length];
 
472
        pos[length]='\0'; // Add temp null terminator for store()
470
473
        field->store((char*) pos,length,read_info.read_charset);
471
474
        pos[length]=save_chr;
472
475
        if ((pos+=length) > read_info.row_end)
720
723
*/
721
724
 
722
725
 
723
 
READ_INFO::READ_INFO(File file_par, uint32_t tot_length, const CHARSET_INFO * const cs,
 
726
READ_INFO::READ_INFO(File file_par, size_t tot_length,
 
727
                     const CHARSET_INFO * const cs,
724
728
                     String &field_term, String &line_start, String &line_term,
725
729
                     String &enclosed_par, int escape, bool is_fifo)
726
730
  :file(file_par),escape_char(escape)
761
765
  set_if_bigger(length,line_start.length());
762
766
  stack=stack_pos=(int*) sql_alloc(sizeof(int)*length);
763
767
 
764
 
  if (!(buffer=(unsigned char*) malloc(buff_length+1)))
 
768
  if (!(buffer=(unsigned char*) calloc(1, buff_length+1)))
765
769
    error=1; /* purecov: inspected */
766
770
  else
767
771
  {
793
797
  {
794
798
    if (need_end_io_cache)
795
799
      ::end_io_cache(&cache);
796
 
    free((unsigned char*) buffer);
 
800
    free(buffer);
797
801
    error=1;
798
802
  }
799
803
}