~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/string.c

  • Committer: Jay Pipes
  • Date: 2008-07-17 20:11:46 UTC
  • mto: This revision was merged to the branch mainline in revision 182.
  • Revision ID: jay@mysql.com-20080717201146-s2flcwwq0q89ac1y
Phase 3 removal of DBUG in mysys

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
                            size_t init_alloc, size_t alloc_increment)
27
27
{
28
28
  uint length;
29
 
  DBUG_ENTER("init_dynamic_string");
30
29
 
31
30
  if (!alloc_increment)
32
31
    alloc_increment=128;
37
36
    init_alloc=alloc_increment;
38
37
 
39
38
  if (!(str->str=(char*) my_malloc(init_alloc,MYF(MY_WME))))
40
 
    DBUG_RETURN(true);
 
39
    return(true);
41
40
  str->length=length-1;
42
41
  if (init_str)
43
42
    memcpy(str->str,init_str,length);
44
43
  str->max_length=init_alloc;
45
44
  str->alloc_increment=alloc_increment;
46
 
  DBUG_RETURN(false);
 
45
  return(false);
47
46
}
48
47
 
49
48
 
50
49
bool dynstr_set(DYNAMIC_STRING *str, const char *init_str)
51
50
{
52
51
  uint length=0;
53
 
  DBUG_ENTER("dynstr_set");
54
52
 
55
53
  if (init_str && (length= (uint) strlen(init_str)+1) > str->max_length)
56
54
  {
59
57
    if (!str->max_length)
60
58
      str->max_length=str->alloc_increment;
61
59
    if (!(str->str=(char*) my_realloc(str->str,str->max_length,MYF(MY_WME))))
62
 
      DBUG_RETURN(true);
 
60
      return(true);
63
61
  }
64
62
  if (init_str)
65
63
  {
68
66
  }
69
67
  else
70
68
    str->length=0;
71
 
  DBUG_RETURN(false);
 
69
  return(false);
72
70
}
73
71
 
74
72
 
75
73
bool dynstr_realloc(DYNAMIC_STRING *str, size_t additional_size)
76
74
{
77
 
  DBUG_ENTER("dynstr_realloc");
78
 
 
79
 
  if (!additional_size) DBUG_RETURN(false);
 
75
  if (!additional_size) return(false);
80
76
  if (str->length + additional_size > str->max_length)
81
77
  {
82
78
    str->max_length=((str->length + additional_size+str->alloc_increment-1)/
83
79
                     str->alloc_increment)*str->alloc_increment;
84
80
    if (!(str->str=(char*) my_realloc(str->str,str->max_length,MYF(MY_WME))))
85
 
      DBUG_RETURN(true);
 
81
      return(true);
86
82
  }
87
 
  DBUG_RETURN(false);
 
83
  return(false);
88
84
}
89
85
 
90
86