~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzletest.cc

  • Committer: Mark Atwood
  • Date: 2011-06-16 06:04:05 UTC
  • mfrom: (2318.4.8 refactor7)
  • Revision ID: me@mark.atwood.name-20110616060405-jqxvti75k6bpq741
mergeĀ lp:~olafvdspek/drizzle/refactor9

Show diffs side-by-side

added added

removed removed

Lines of Context:
234
234
{
235
235
  drizzle_st* drizzle;
236
236
  drizzle_con_st con;
237
 
  /* Used when creating views and sp, to avoid implicit commit */
238
 
  drizzle_con_st* util_con;
239
237
  char* name;
240
238
};
241
239
st_connection g_connections[128];
6569
6567
    char *substring_to_replace= in_string + ovector[0];
6570
6568
    int substring_length= ovector[1] - ovector[0];
6571
6569
    *buf_len_p= strlen(in_string) - substring_length + strlen(replace);
6572
 
    char * new_buf = (char *)malloc(*buf_len_p+1);
6573
 
    if (new_buf == NULL)
6574
 
    {
6575
 
      pcre_free(re);
6576
 
      return 1;
6577
 
    }
 
6570
    char* new_buf= (char*)malloc(*buf_len_p+1);
6578
6571
 
6579
6572
    memset(new_buf, 0, *buf_len_p+1);
6580
6573
    strncpy(new_buf, in_string, substring_to_replace-in_string);
6613
6606
      current_position= current_position + length_of_replacement;
6614
6607
    }
6615
6608
 
6616
 
    char *new_buf = (char *) malloc(subject.length() + 1);
6617
 
    if (new_buf == NULL)
6618
 
    {
6619
 
      pcre_free(re);
6620
 
      return 1;
6621
 
    }
 
6609
    char* new_buf = (char*) malloc(subject.length() + 1);
6622
6610
    memset(new_buf, 0, subject.length() + 1);
6623
6611
    strncpy(new_buf, subject.c_str(), subject.length());
6624
6612
    *buf_len_p= subject.length() + 1;
6684
6672
  uint32_t len;
6685
6673
};
6686
6674
 
6687
 
int init_sets(REP_SETS *sets, uint32_t states);
 
6675
void init_sets(REP_SETS *sets, uint32_t states);
6688
6676
REP_SET *make_new_set(REP_SETS *sets);
6689
6677
int find_found(FOUND_SET *found_set, uint32_t table_offset, int found_offset);
6690
6678
 
6750
6738
  REP_SETS sets;
6751
6739
  REP_SET *set,*start_states,*word_states,*new_set;
6752
6740
  REPLACE_STRING *rep_str;
6753
 
  if (init_sets(&sets, states))
6754
 
    return 0;
 
6741
  init_sets(&sets, states);
6755
6742
  found_sets=0;
6756
6743
  vector<FOUND_SET> found_set(max_length * count);
6757
6744
  make_new_set(&sets);      /* Set starting set */
6943
6930
 
6944
6931
  REPLACE *replace= (REPLACE*)malloc(sizeof(REPLACE) * (sets.count)
6945
6932
    + sizeof(REPLACE_STRING) * (found_sets + 1) + sizeof(char*) * count + result_len);
6946
 
  if (replace)
6947
6933
  {
6948
6934
    memset(replace, 0, sizeof(REPLACE)*(sets.count)+
6949
6935
                       sizeof(REPLACE_STRING)*(found_sets+1)+
6980
6966
}
6981
6967
 
6982
6968
 
6983
 
int init_sets(REP_SETS *sets,uint32_t states)
 
6969
void init_sets(REP_SETS *sets,uint32_t states)
6984
6970
{
6985
6971
  memset(sets, 0, sizeof(*sets));
6986
6972
  sets->size_of_bits=((states+7)/8);
6987
 
  if (!(sets->set_buffer=(REP_SET*) malloc(sizeof(REP_SET)*SET_MALLOC_HUNC)))
6988
 
    return 1;
6989
 
  if (!(sets->bit_buffer=(uint*) malloc(sizeof(uint32_t)*sets->size_of_bits*
6990
 
                                        SET_MALLOC_HUNC)))
6991
 
  {
6992
 
    free(sets->set);
6993
 
    return 1;
6994
 
  }
6995
 
  return 0;
 
6973
  sets->set_buffer=(REP_SET*) malloc(sizeof(REP_SET) * SET_MALLOC_HUNC);
 
6974
  sets->bit_buffer=(uint*) malloc(sizeof(uint32_t) * sets->size_of_bits * SET_MALLOC_HUNC);
6996
6975
}
6997
6976
 
6998
6977
/* Make help sets invisible for nicer codeing */
7006
6985
 
7007
6986
REP_SET *make_new_set(REP_SETS *sets)
7008
6987
{
7009
 
  uint32_t i,count,*bit_buffer;
7010
6988
  REP_SET *set;
7011
6989
  if (sets->extra)
7012
6990
  {
7020
6998
    set->size_of_bits=sets->size_of_bits;
7021
6999
    return set;
7022
7000
  }
7023
 
  count=sets->count+sets->invisible+SET_MALLOC_HUNC;
7024
 
  if (!(set=(REP_SET*) realloc((unsigned char*) sets->set_buffer,
7025
 
                                  sizeof(REP_SET)*count)))
7026
 
    return 0;
 
7001
  uint32_t count= sets->count + sets->invisible + SET_MALLOC_HUNC;
 
7002
  set= (REP_SET*) realloc((unsigned char*) sets->set_buffer, sizeof(REP_SET)*count);
7027
7003
  sets->set_buffer=set;
7028
7004
  sets->set=set+sets->invisible;
7029
 
  if (!(bit_buffer=(uint*) realloc((unsigned char*) sets->bit_buffer,
7030
 
                                   (sizeof(uint32_t)*sets->size_of_bits)*count)))
7031
 
    return 0;
 
7005
  uint32_t* bit_buffer= (uint*) realloc((unsigned char*) sets->bit_buffer, (sizeof(uint32_t)*sets->size_of_bits)*count);
7032
7006
  sets->bit_buffer=bit_buffer;
7033
 
  for (i=0 ; i < count ; i++)
 
7007
  for (uint32_t i= 0; i < count; i++)
7034
7008
  {
7035
7009
    sets->set_buffer[i].bits=bit_buffer;
7036
7010
    bit_buffer+=sets->size_of_bits;
7155
7129
 
7156
7130
  if (! pa->typelib.count)
7157
7131
  {
7158
 
    if (!(pa->typelib.type_names=(const char **)
 
7132
    pa->typelib.type_names=(const char **)
7159
7133
          malloc(((PC_MALLOC-MALLOC_OVERHEAD)/
7160
7134
                     (sizeof(char *)+sizeof(*pa->flag))*
7161
 
                     (sizeof(char *)+sizeof(*pa->flag))))))
7162
 
      return(-1);
7163
 
    if (!(pa->str= (unsigned char*) malloc(PS_MALLOC-MALLOC_OVERHEAD)))
7164
 
    {
7165
 
      free((char*) pa->typelib.type_names);
7166
 
      return (-1);
7167
 
    }
 
7135
                     (sizeof(char *)+sizeof(*pa->flag))));
 
7136
    pa->str= (unsigned char*) malloc(PS_MALLOC-MALLOC_OVERHEAD);
7168
7137
    pa->max_count=(PC_MALLOC-MALLOC_OVERHEAD)/(sizeof(unsigned char*)+
7169
7138
                                               sizeof(*pa->flag));
7170
7139
    pa->flag= (uint8_t*) (pa->typelib.type_names+pa->max_count);
7175
7144
  length=(uint32_t) strlen(name)+1;
7176
7145
  if (pa->length+length >= pa->max_length)
7177
7146
  {
7178
 
    if (!(new_pos= (unsigned char*)realloc((unsigned char*)pa->str,
7179
 
                                           (size_t)(pa->max_length+PS_MALLOC))))
7180
 
      return(1);
 
7147
    new_pos= (unsigned char*)realloc((unsigned char*)pa->str, (size_t)(pa->max_length+PS_MALLOC));
7181
7148
    if (new_pos != pa->str)
7182
7149
    {
7183
7150
      ptrdiff_t diff= PTR_BYTE_DIFF(new_pos,pa->str);
7193
7160
    size_t len;
7194
7161
    pa->array_allocs++;
7195
7162
    len=(PC_MALLOC*pa->array_allocs - MALLOC_OVERHEAD);
7196
 
    if (!(new_array=
7197
 
         (const char **)realloc((unsigned char*) pa->typelib.type_names,
 
7163
    new_array= (const char **)realloc((unsigned char*) pa->typelib.type_names,
7198
7164
                                 len/
7199
7165
                                  (sizeof(unsigned char*)+sizeof(*pa->flag))*
7200
 
                                  (sizeof(unsigned char*)+sizeof(*pa->flag)))))
7201
 
      return(1);
 
7166
                                  (sizeof(unsigned char*)+sizeof(*pa->flag)));
7202
7167
    pa->typelib.type_names=new_array;
7203
7168
    old_count=pa->max_count;
7204
7169
    pa->max_count=len/(sizeof(unsigned char*) + sizeof(*pa->flag));