~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/string.c

  • Committer: Brian Aker
  • Date: 2008-07-15 06:45:16 UTC
  • Revision ID: brian@tangent.org-20080715064516-fnbq7kowh7w57bxj
Merge Monty's code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
    init_alloc=alloc_increment;
38
38
 
39
39
  if (!(str->str=(char*) my_malloc(init_alloc,MYF(MY_WME))))
40
 
    DBUG_RETURN(TRUE);
 
40
    DBUG_RETURN(true);
41
41
  str->length=length-1;
42
42
  if (init_str)
43
43
    memcpy(str->str,init_str,length);
44
44
  str->max_length=init_alloc;
45
45
  str->alloc_increment=alloc_increment;
46
 
  DBUG_RETURN(FALSE);
 
46
  DBUG_RETURN(false);
47
47
}
48
48
 
49
49
 
59
59
    if (!str->max_length)
60
60
      str->max_length=str->alloc_increment;
61
61
    if (!(str->str=(char*) my_realloc(str->str,str->max_length,MYF(MY_WME))))
62
 
      DBUG_RETURN(TRUE);
 
62
      DBUG_RETURN(true);
63
63
  }
64
64
  if (init_str)
65
65
  {
68
68
  }
69
69
  else
70
70
    str->length=0;
71
 
  DBUG_RETURN(FALSE);
 
71
  DBUG_RETURN(false);
72
72
}
73
73
 
74
74
 
76
76
{
77
77
  DBUG_ENTER("dynstr_realloc");
78
78
 
79
 
  if (!additional_size) DBUG_RETURN(FALSE);
 
79
  if (!additional_size) DBUG_RETURN(false);
80
80
  if (str->length + additional_size > str->max_length)
81
81
  {
82
82
    str->max_length=((str->length + additional_size+str->alloc_increment-1)/
83
83
                     str->alloc_increment)*str->alloc_increment;
84
84
    if (!(str->str=(char*) my_realloc(str->str,str->max_length,MYF(MY_WME))))
85
 
      DBUG_RETURN(TRUE);
 
85
      DBUG_RETURN(true);
86
86
  }
87
 
  DBUG_RETURN(FALSE);
 
87
  DBUG_RETURN(false);
88
88
}
89
89
 
90
90
 
104
104
      str->alloc_increment;
105
105
    new_length*=str->alloc_increment;
106
106
    if (!(new_ptr=(char*) my_realloc(str->str,new_length,MYF(MY_WME))))
107
 
      return TRUE;
 
107
      return true;
108
108
    str->str=new_ptr;
109
109
    str->max_length=new_length;
110
110
  }
111
111
  memcpy(str->str + str->length,append,length);
112
112
  str->length+=length;
113
113
  str->str[str->length]=0;                      /* Safety for C programs */
114
 
  return FALSE;
 
114
  return false;
115
115
}
116
116
 
117
117
 
119
119
{
120
120
  str->length-=n;
121
121
  str->str[str->length]= '\0';
122
 
  return FALSE;
 
122
  return false;
123
123
}
124
124
 
125
125
/*
142
142
{
143
143
  const char *quote_str= "\'";
144
144
  const uint  quote_len= 1;
145
 
  bool ret= TRUE;
 
145
  bool ret= true;
146
146
  va_list dirty_text;
147
147
 
148
148
  ret&= dynstr_append_mem(str, quote_str, quote_len); /* Leading quote */