mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 12:32:27 +01:00
1e87cfee19
- Removed not used variables - Changed some ulong parameters/variables to ulonglong (possible serious bug) - Added casts to get rid of safe assignment from longlong to long (and similar) - Added casts to function parameters - Fixed signed/unsigned compares - Added some constructores to structures - Removed some not portable constructs Better fix for bug Bug #21428 "skipped 9 bytes from file: socket (3)" on "mysqladmin shutdown" (Added new parameter to net_clear() to define when we want the communication buffer to be emptied) client/mysql.cc: Removed not used variable client/mysqldump.c: Fixed compiler warning client/mysqlslap.c: Fixed compiler warning client/mysqltest.c: Fixed compiler warning extra/replace.c: Fixed compiler warning include/my_global.h: Fixed compiler warning include/mysql_com.h: Changed prototype for net_clear() libmysql/libmysql.c: Changed prototype for net_clear() mysys/base64.c: Fixed compiler warning (function definition and prototype didn't match) mysys/my_thr_init.c: AFter merge fixes mysys/my_vle.c: Fixed compiler warning sql/event_data_objects.cc: Fixed compiler warning sql/event_scheduler.cc: Removed not used variable sql/field.cc: Removed not used variables Fixed compiler warning sql/gen_lex_hash.cc: Fixed compiler warning sql/ha_partition.h: Fixed compiler warning sql/handler.cc: Fixed compiler warning sql/item.cc: Fixed compiler warning sql/item_create.cc: Fixed compiler warning sql/item_func.cc: Fixed compiler warning sql/item_strfunc.cc: Fixed compiler warning sql/item_timefunc.cc: Fixed compiler warning sql/item_xmlfunc.cc: Fixed compiler warning sql/log.cc: Fixed compiler warning sql/log_event.cc: Fixed compiler warning sql/log_event.h: Fixed compiler warning sql/mysql_priv.h: Fixed too short 'select_type' sql/net_serv.cc: Added argument to net_clear() if we should empty the communication buffer. sql/opt_range.cc: Fixed compiler warning sql/partition_info.cc: Fixed compiler warning sql/rpl_injector.h: Fixed compiler warning sql/set_var.cc: Fixed compiler warning sql/slave.cc: Fixed compiler warning sql/sp_head.cc: Fixed compiler warning sql/sql_base.cc: Fixed compiler warning sql/sql_db.cc: Fixed compiler warning sql/sql_delete.cc: Fixed compiler warning sql/sql_insert.cc: Fixed compiler warning sql/sql_lex.h: Fixed compiler warning sql/sql_parse.cc: Fixed compiler warning sql/sql_partition.cc: Fixed compiler warning sql/sql_plugin.cc: Fixed compiler warning sql/sql_prepare.cc: Fixed compiler warning sql/sql_rename.cc: Fixed compiler warning sql/sql_select.cc: Fixed compiler warning sql/sql_show.cc: Fixed compiler warning sql/sql_table.cc: Fixed compiler warning sql/sql_trigger.cc: Fixed compiler warning sql-common/client.c: Better fix for bug Bug #21428 "skipped 9 bytes from file: socket (3)" on "mysqladmin shutdown" sql-common/my_time.c: Fixed compiler warning sql/sql_union.cc: Fixed compiler warning sql/sql_update.cc: Fixed compiler warning sql/sql_view.cc: Fixed compiler warning sql/sql_yacc.yy: Fixed compiler warning sql/table.cc: Fixed compiler warning storage/archive/azio.c: Fixed compiler warning storage/csv/ha_tina.cc: Removed not used code storage/myisam/mi_unique.c: Fixed compiler warning storage/ndb/include/util/OutputStream.hpp: Fixed compiler warning storage/ndb/include/util/SocketAuthenticator.hpp: Fixed compiler warning storage/ndb/src/kernel/vm/Pool.hpp: Fixed compiler warning strings/ctype-simple.c: Fixed compiler warning strings/my_strchr.c: Fixed compiler warning
113 lines
2.6 KiB
C
113 lines
2.6 KiB
C
/*
|
|
Copyright (C) 2005 MySQL AB
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU General Public License as
|
|
published by the Free Software Foundation; either version 2 of the
|
|
License, or (at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful, but
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
USA
|
|
*/
|
|
|
|
/*
|
|
Variable length encoding.
|
|
|
|
A method to store an arbitrary-size non-negative integer. We let the
|
|
most significant bit of the number indicate that the next byte
|
|
should be contatenated to form the real number.
|
|
*/
|
|
|
|
#include "my_vle.h"
|
|
|
|
/*
|
|
Function to encode an unsigned long as VLE. The bytes for the VLE
|
|
will be written to the location pointed to by 'out'. The maximum
|
|
number of bytes written will be 'max'.
|
|
|
|
PARAMETERS
|
|
|
|
out Pointer to beginning of where to store VLE bytes.
|
|
max Maximum number of bytes to write.
|
|
n Number to encode.
|
|
|
|
RETURN VALUE
|
|
On success, one past the end of the array containing the VLE
|
|
bytes. On failure, the 'out' pointer is returned.
|
|
*/
|
|
|
|
byte*
|
|
my_vle_encode(byte* out, my_size_t max, ulong n)
|
|
{
|
|
byte buf[my_vle_sizeof(n)];
|
|
byte *ptr= buf;
|
|
my_size_t len;
|
|
|
|
do
|
|
{
|
|
*ptr++= (byte) (n & 0x7F);
|
|
n>>= 7;
|
|
}
|
|
while (n > 0);
|
|
|
|
len= ptr - buf;
|
|
|
|
if (len <= max)
|
|
{
|
|
/*
|
|
The bytes are stored in reverse order in 'buf'. Let's write them
|
|
in correct order to the output buffer and set the MSB at the
|
|
same time.
|
|
*/
|
|
while (ptr-- > buf)
|
|
{
|
|
byte v= *ptr;
|
|
if (ptr > buf)
|
|
v|= 0x80;
|
|
*out++= v;
|
|
}
|
|
}
|
|
|
|
return out;
|
|
}
|
|
|
|
/*
|
|
Function to decode a VLE representation of an integral value.
|
|
|
|
|
|
PARAMETERS
|
|
|
|
result_ptr Pointer to an unsigned long where the value will be written.
|
|
vle Pointer to the VLE bytes.
|
|
|
|
RETURN VALUE
|
|
|
|
One-past the end of the VLE bytes. The routine will never read
|
|
more than sizeof(*result_ptr) + 1 bytes.
|
|
*/
|
|
|
|
byte const*
|
|
my_vle_decode(ulong *result_ptr, byte const *vle)
|
|
{
|
|
ulong result= 0;
|
|
my_size_t cnt= 1;
|
|
|
|
do
|
|
{
|
|
result<<= 7;
|
|
result|= (*vle & 0x7F);
|
|
}
|
|
while ((*vle++ & 0x80) && ++cnt <= sizeof(*result_ptr) + 1);
|
|
|
|
if (cnt <= sizeof(*result_ptr) + 1)
|
|
*result_ptr= result;
|
|
|
|
return vle;
|
|
}
|