Skip to content

Commit a53cce1

Browse files
committed
Bug#19729545: REMOVE UNNEEDED CMAKE CHECKS AND #IFDEFS IN 5.7.6
Patch mysql#2: As a consequence of earlier patches, my_afree() is no longer needed. Remove all usage of it.
1 parent 89e9ddc commit a53cce1

22 files changed

+24
-132
lines changed

include/my_sys.h

-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ extern uint my_large_page_size;
205205
#endif /* HAVE_LINUX_LARGE_PAGES */
206206

207207
#define my_alloca(SZ) alloca((size_t) (SZ))
208-
#define my_afree(PTR) {}
209208

210209
#include <errno.h> /* errno is a define */
211210

libmysqld/lib_sql.cc

-3
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,6 @@ emb_transfer_connect_attrs(MYSQL *mysql)
760760
send_client_connect_attrs(mysql, buf);
761761
net_field_length_ll(&ptr);
762762
PSI_THREAD_CALL(set_thread_connect_attrs)((char *) ptr, length, thd->charset());
763-
my_afree(buf);
764763
}
765764
#endif
766765
}
@@ -860,14 +859,12 @@ int check_embedded_connection(MYSQL *mysql, const char *db)
860859
x_free(thd->security_context()->user().str);
861860
goto err;
862861
}
863-
my_afree(buf);
864862
return 0;
865863
err:
866864
strmake(net->last_error, thd->main_da.message(), sizeof(net->last_error)-1);
867865
memcpy(net->sqlstate,
868866
mysql_errno_to_sqlstate(thd->main_da.sql_errno()),
869867
sizeof(net->sqlstate)-1);
870-
my_afree(buf);
871868
return 1;
872869
}
873870
#endif

mysys/mf_iocache2.c

-2
Original file line numberDiff line numberDiff line change
@@ -446,10 +446,8 @@ size_t my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args)
446446
memset(buffz, ' ', minimum_width - length2);
447447
if (my_b_write(info, buffz, minimum_width - length2))
448448
{
449-
my_afree(buffz);
450449
goto err;
451450
}
452-
my_afree(buffz);
453451
}
454452

455453
out_length+= length2;

mysys/mf_qsort.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -200,6 +200,5 @@ void my_qsort(void *base_ptr, size_t count, size_t size, qsort_cmp cmp)
200200
high = high_ptr;
201201
}
202202
} while (stack_ptr > stack);
203-
my_afree(pivot);
204203
return;
205204
}

sql-common/client.c

+1-4
Original file line numberDiff line numberDiff line change
@@ -3256,7 +3256,6 @@ static int send_change_user_packet(MCPVIO_EXT *mpvio,
32563256
(uchar*)buff, (ulong)(end-buff), 1);
32573257

32583258
error:
3259-
my_afree(buff);
32603259
return res;
32613260
}
32623261

@@ -3608,11 +3607,9 @@ static int send_client_reply_packet(MCPVIO_EXT *mpvio,
36083607
goto error;
36093608
}
36103609
MYSQL_TRACE(PACKET_SENT, mysql, (end-buff));
3611-
my_afree(buff);
36123610
return 0;
3613-
3611+
36143612
error:
3615-
my_afree(buff);
36163613
return 1;
36173614
}
36183615

sql/auth/sql_authentication.cc

-1
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,6 @@ static bool send_server_handshake_packet(MPVIO_EXT *mpvio,
658658

659659
int res= my_net_write(mpvio->net, (uchar*) buff, (size_t) (end - buff + 1)) ||
660660
net_flush(mpvio->net);
661-
my_afree(buff);
662661
DBUG_RETURN (res);
663662
}
664663

sql/field.cc

-1
Original file line numberDiff line numberDiff line change
@@ -9570,7 +9570,6 @@ Field_bit::unpack(uchar *to, const uchar *from, uint param_data,
95709570
value[new_len - len]= value[new_len - len] & ((1U << from_bit_len) - 1);
95719571
bitmap_set_bit(table->write_set,field_index);
95729572
store(value, new_len, system_charset_info);
9573-
my_afree(value);
95749573
DBUG_RETURN(from + len);
95759574
}
95769575

sql/ha_ndbcluster_push.cc

-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,6 @@ NdbQuery* ndb_pushed_join::make_query_instance(
266266
{
267267
extendedParams[i].~NdbQueryParamValue();
268268
}
269-
my_afree(extendedParams);
270269
}
271270
DBUG_RETURN(query);
272271
}

sql/ha_partition.cc

-3
Original file line numberDiff line numberDiff line change
@@ -2939,8 +2939,6 @@ bool ha_partition::setup_engine_array(MEM_ROOT *mem_root)
29392939
}
29402940
}
29412941

2942-
my_afree((gptr) engine_array);
2943-
29442942
if (create_handlers(mem_root))
29452943
{
29462944
clear_handler_file();
@@ -2950,7 +2948,6 @@ bool ha_partition::setup_engine_array(MEM_ROOT *mem_root)
29502948
DBUG_RETURN(false);
29512949

29522950
err:
2953-
my_afree((gptr) engine_array);
29542951
DBUG_RETURN(true);
29552952
}
29562953

sql/log_event.cc

+6-6
Original file line numberDiff line numberDiff line change
@@ -11897,7 +11897,7 @@ Write_rows_log_event::write_row(const Relay_log_info *const rli,
1189711897
TABLE *table= m_table; // pointer to event's table
1189811898
int error;
1189911899
int keynum= 0;
11900-
auto_afree_ptr<char> key(NULL);
11900+
char* key= NULL;
1190111901

1190211902
prepare_record(table, &m_cols,
1190311903
table->file->ht->db_type != DB_TYPE_NDBCLUSTER);
@@ -12023,10 +12023,10 @@ Write_rows_log_event::write_row(const Relay_log_info *const rli,
1202312023
goto error;
1202412024
}
1202512025

12026-
if (key.get() == NULL)
12026+
if (key == NULL)
1202712027
{
12028-
key.assign(static_cast<char*>(my_alloca(table->s->max_unique_length)));
12029-
if (key.get() == NULL)
12028+
key= static_cast<char*>(my_alloca(table->s->max_unique_length));
12029+
if (key == NULL)
1203012030
{
1203112031
DBUG_PRINT("info",("Can't allocate key buffer"));
1203212032
error= ENOMEM;
@@ -12036,10 +12036,10 @@ Write_rows_log_event::write_row(const Relay_log_info *const rli,
1203612036

1203712037
if ((uint)keynum < MAX_KEY)
1203812038
{
12039-
key_copy((uchar*)key.get(), table->record[0], table->key_info + keynum,
12039+
key_copy((uchar*)key, table->record[0], table->key_info + keynum,
1204012040
0);
1204112041
error= table->file->ha_index_read_idx_map(table->record[1], keynum,
12042-
(const uchar*)key.get(),
12042+
(const uchar*)key,
1204312043
HA_WHOLE_KEY,
1204412044
HA_READ_KEY_EXACT);
1204512045
}

sql/log_event_old.cc

+12-12
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ replace_record(THD *thd, TABLE *table,
527527

528528
int error;
529529
int keynum;
530-
auto_afree_ptr<char> key(NULL);
530+
char *key= NULL;
531531

532532
#ifndef DBUG_OFF
533533
DBUG_DUMP("record[0]", table->record[0], table->s->reclength);
@@ -596,19 +596,19 @@ replace_record(THD *thd, TABLE *table,
596596
DBUG_RETURN(my_errno);
597597
}
598598

599-
if (key.get() == NULL)
599+
if (key == NULL)
600600
{
601-
key.assign(static_cast<char*>(my_alloca(table->s->max_unique_length)));
602-
if (key.get() == NULL)
601+
key= static_cast<char*>(my_alloca(table->s->max_unique_length));
602+
if (key == NULL)
603603
DBUG_RETURN(ENOMEM);
604604
}
605605

606606
if ((uint)keynum < MAX_KEY)
607607
{
608-
key_copy((uchar*)key.get(), table->record[0], table->key_info + keynum,
608+
key_copy((uchar*)key, table->record[0], table->key_info + keynum,
609609
0);
610610
error= table->file->ha_index_read_idx_map(table->record[1], keynum,
611-
(const uchar*)key.get(),
611+
(const uchar*)key,
612612
HA_WHOLE_KEY,
613613
HA_READ_KEY_EXACT);
614614
}
@@ -2021,7 +2021,7 @@ Old_rows_log_event::write_row(const Relay_log_info *const rli,
20212021
TABLE *table= m_table; // pointer to event's table
20222022
int error;
20232023
int keynum;
2024-
auto_afree_ptr<char> key(NULL);
2024+
char *key= NULL;
20252025

20262026
/* fill table->record[0] with default values */
20272027

@@ -2110,10 +2110,10 @@ Old_rows_log_event::write_row(const Relay_log_info *const rli,
21102110
DBUG_RETURN(my_errno);
21112111
}
21122112

2113-
if (key.get() == NULL)
2113+
if (key == NULL)
21142114
{
2115-
key.assign(static_cast<char*>(my_alloca(table->s->max_unique_length)));
2116-
if (key.get() == NULL)
2115+
key= static_cast<char*>(my_alloca(table->s->max_unique_length));
2116+
if (key == NULL)
21172117
{
21182118
DBUG_PRINT("info",("Can't allocate key buffer"));
21192119
DBUG_RETURN(ENOMEM);
@@ -2122,10 +2122,10 @@ Old_rows_log_event::write_row(const Relay_log_info *const rli,
21222122

21232123
if ((uint)keynum < MAX_KEY)
21242124
{
2125-
key_copy((uchar*)key.get(), table->record[0], table->key_info + keynum,
2125+
key_copy((uchar*)key, table->record[0], table->key_info + keynum,
21262126
0);
21272127
error= table->file->ha_index_read_idx_map(table->record[1], keynum,
2128-
(const uchar*)key.get(),
2128+
(const uchar*)key,
21292129
HA_WHOLE_KEY,
21302130
HA_READ_KEY_EXACT);
21312131
}

sql/rpl_utility.h

-30
Original file line numberDiff line numberDiff line change
@@ -430,36 +430,6 @@ struct RPL_TABLE_LIST
430430
};
431431

432432

433-
/* Anonymous namespace for template functions/classes */
434-
namespace {
435-
436-
/*
437-
Smart pointer that will automatically call my_afree (a macro) when
438-
the pointer goes out of scope. This is used so that I do not have
439-
to remember to call my_afree() before each return. There is no
440-
overhead associated with this, since all functions are inline.
441-
442-
I (Matz) would prefer to use the free function as a template
443-
parameter, but that is not possible when the "function" is a
444-
macro.
445-
*/
446-
template <class Obj>
447-
class auto_afree_ptr
448-
{
449-
Obj* m_ptr;
450-
public:
451-
auto_afree_ptr(Obj* ptr) : m_ptr(ptr) { }
452-
~auto_afree_ptr() { if (m_ptr) my_afree(m_ptr); }
453-
void assign(Obj* ptr) {
454-
/* Only to be called if it hasn't been given a value before. */
455-
DBUG_ASSERT(m_ptr == NULL);
456-
m_ptr= ptr;
457-
}
458-
Obj* get() { return m_ptr; }
459-
};
460-
461-
} // namespace
462-
463433
class Deferred_log_events
464434
{
465435
private:

sql/sql_plugin.cc

-10
Original file line numberDiff line numberDiff line change
@@ -1034,8 +1034,6 @@ static void reap_plugins(void)
10341034
plugin_del(plugin);
10351035

10361036
mysql_mutex_unlock(&LOCK_plugin_delete);
1037-
1038-
my_afree(reap);
10391037
}
10401038

10411039
static void intern_plugin_unlock(LEX *lex, plugin_ref plugin)
@@ -1475,7 +1473,6 @@ int plugin_init(int *argc, char **argv, int flags)
14751473
}
14761474

14771475
mysql_mutex_unlock(&LOCK_plugin);
1478-
my_afree(reap);
14791476
if (reaped_mandatory_plugin)
14801477
goto err;
14811478

@@ -1835,8 +1832,6 @@ void plugin_shutdown(void)
18351832
initialized= 0;
18361833
mysql_mutex_destroy(&LOCK_plugin);
18371834
mysql_mutex_destroy(&LOCK_plugin_delete);
1838-
1839-
my_afree(plugins);
18401835
}
18411836

18421837
/* Dispose of the memory */
@@ -1854,7 +1849,6 @@ void plugin_shutdown(void)
18541849
dl[i]= plugin_dl_array->at(i);
18551850
for (i= 0; i < plugin_dl_array->size(); i++)
18561851
free_plugin_mem(dl[i]);
1857-
my_afree(dl);
18581852
delete plugin_dl_array;
18591853
plugin_dl_array= NULL;
18601854
}
@@ -2223,10 +2217,8 @@ bool plugin_foreach_with_mask(THD *thd, plugin_foreach_func *func,
22232217
goto err;
22242218
}
22252219

2226-
my_afree(plugins);
22272220
DBUG_RETURN(FALSE);
22282221
err:
2229-
my_afree(plugins);
22302222
DBUG_RETURN(TRUE);
22312223
}
22322224

@@ -2633,7 +2625,6 @@ static st_bookmark *find_bookmark(const char *plugin, const char *name,
26332625
result= (st_bookmark*) my_hash_search(&bookmark_hash,
26342626
(const uchar*) varname, length - 1);
26352627

2636-
my_afree(varname);
26372628
return result;
26382629
}
26392630

@@ -2755,7 +2746,6 @@ static st_bookmark *register_var(const char *plugin, const char *name,
27552746
DBUG_ASSERT(0);
27562747
}
27572748
}
2758-
my_afree(varname);
27592749
return result;
27602750
}
27612751

storage/myisam/mi_check.c

-14
Original file line numberDiff line numberDiff line change
@@ -872,10 +872,8 @@ static int chk_index(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo,
872872
llstr(page,llbuff), used_length, (keypos - buff));
873873
goto err;
874874
}
875-
my_afree((uchar*) temp_buff);
876875
DBUG_RETURN(0);
877876
err:
878-
my_afree((uchar*) temp_buff);
879877
DBUG_RETURN(1);
880878
} /* chk_index */
881879

@@ -2109,10 +2107,8 @@ static int sort_one_index(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo,
21092107
mi_check_print_error(param,"Can't write indexblock, error: %d",my_errno);
21102108
goto err;
21112109
}
2112-
my_afree((uchar*) buff);
21132110
DBUG_RETURN(0);
21142111
err:
2115-
my_afree((uchar*) buff);
21162112
DBUG_RETURN(1);
21172113
} /* sort_one_index */
21182114

@@ -4220,22 +4216,16 @@ int recreate_table(MI_CHECK *param, MI_INFO **org_info, char *filename)
42204216
if (!(keysegs=(HA_KEYSEG*) my_alloca(sizeof(HA_KEYSEG)*
42214217
(key_parts+share.base.keys))))
42224218
{
4223-
my_afree((uchar*) keyinfo);
42244219
DBUG_RETURN(1);
42254220
}
42264221
if (!(recdef=(MI_COLUMNDEF*)
42274222
my_alloca(sizeof(MI_COLUMNDEF)*(share.base.fields+1))))
42284223
{
4229-
my_afree((uchar*) keyinfo);
4230-
my_afree((uchar*) keysegs);
42314224
DBUG_RETURN(1);
42324225
}
42334226
if (!(uniquedef=(MI_UNIQUEDEF*)
42344227
my_alloca(sizeof(MI_UNIQUEDEF)*(share.state.header.uniques+1))))
42354228
{
4236-
my_afree((uchar*) recdef);
4237-
my_afree((uchar*) keyinfo);
4238-
my_afree((uchar*) keysegs);
42394229
DBUG_RETURN(1);
42404230
}
42414231

@@ -4353,10 +4343,6 @@ int recreate_table(MI_CHECK *param, MI_INFO **org_info, char *filename)
43534343
goto end;
43544344
error=0;
43554345
end:
4356-
my_afree((uchar*) uniquedef);
4357-
my_afree((uchar*) keyinfo);
4358-
my_afree((uchar*) recdef);
4359-
my_afree((uchar*) keysegs);
43604346
DBUG_RETURN(error);
43614347
}
43624348

0 commit comments

Comments
 (0)