~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_compress.c

  • Committer: Jay Pipes
  • Date: 2008-07-17 21:21:21 UTC
  • mto: This revision was merged to the branch mainline in revision 182.
  • Revision ID: jay@mysql.com-20080717212121-5qx4zm1fbqkz8ss0
Phase 6 - Remove DBUG from mysys

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
 
37
37
bool my_compress(uchar *packet, size_t *len, size_t *complen)
38
38
{
39
 
  DBUG_ENTER("my_compress");
40
39
  if (*len < MIN_COMPRESS_LENGTH)
41
40
  {
42
41
    *complen=0;
43
 
    DBUG_PRINT("note",("Packet too short: Not compressed"));
44
42
  }
45
43
  else
46
44
  {
47
45
    uchar *compbuf=my_compress_alloc(packet,len,complen);
48
46
    if (!compbuf)
49
 
      DBUG_RETURN(*complen ? 0 : 1);
 
47
      return(*complen ? 0 : 1);
50
48
    memcpy(packet,compbuf,*len);
51
49
    my_free(compbuf,MYF(MY_WME));
52
50
  }
53
 
  DBUG_RETURN(0);
 
51
  return(0);
54
52
}
55
53
 
56
54
 
78
76
  {
79
77
    *complen= 0;
80
78
    my_free(compbuf, MYF(MY_WME));
81
 
    DBUG_PRINT("note",("Packet got longer on compression; Not compressed"));
82
79
    return 0;
83
80
  }
84
81
  /* Store length of compressed packet in *len */
106
103
bool my_uncompress(uchar *packet, size_t len, size_t *complen)
107
104
{
108
105
  uLongf tmp_complen;
109
 
  DBUG_ENTER("my_uncompress");
110
106
 
111
107
  if (*complen)                                 /* If compressed */
112
108
  {
113
109
    uchar *compbuf= (uchar *) my_malloc(*complen,MYF(MY_WME));
114
110
    int error;
115
111
    if (!compbuf)
116
 
      DBUG_RETURN(1);                           /* Not enough memory */
 
112
      return(1);                                /* Not enough memory */
117
113
 
118
114
    tmp_complen= *complen;
119
115
    error= uncompress((Bytef*) compbuf, &tmp_complen, (Bytef*) packet,
121
117
    *complen= tmp_complen;
122
118
    if (error != Z_OK)
123
119
    {                                           /* Probably wrong packet */
124
 
      DBUG_PRINT("error",("Can't uncompress packet, error: %d",error));
125
120
      my_free(compbuf, MYF(MY_WME));
126
 
      DBUG_RETURN(1);
 
121
      return(1);
127
122
    }
128
123
    memcpy(packet, compbuf, *complen);
129
124
    my_free(compbuf, MYF(MY_WME));
130
125
  }
131
126
  else
132
127
    *complen= len;
133
 
  DBUG_RETURN(0);
 
128
  return(0);
134
129
}