Skip to content

Commit c5c9128

Browse files
committed
cleanup: use multi_alloc_root
1 parent 1fd8b0a commit c5c9128

File tree

1 file changed

+16
-26
lines changed

1 file changed

+16
-26
lines changed

sql/table.cc

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,48 +1431,38 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
14311431

14321432
DBUG_PRINT("info",("i_count: %d i_parts: %d index: %d n_length: %d int_length: %d com_length: %d vcol_screen_length: %d", interval_count,interval_parts, keys,n_length,int_length, com_length, vcol_screen_length));
14331433

1434+
if (!multi_alloc_root(&share->mem_root,
1435+
&share->field, (uint)(share->fields+1)*sizeof(Field*),
1436+
&share->intervals, (uint)interval_count*sizeof(TYPELIB),
1437+
&share->check_constraints, (uint) share->table_check_constraints * sizeof(Virtual_column_info*),
1438+
&interval_array, (uint) (share->fields+interval_parts+ keys+3)*sizeof(char *),
1439+
&names, (uint) (n_length+int_length),
1440+
&comment_pos, (uint) com_length,
1441+
&vcol_screen_pos, vcol_screen_length,
1442+
NullS))
14341443

1435-
if (!(field_ptr = (Field **)
1436-
alloc_root(&share->mem_root,
1437-
(uint) ((share->fields+1)*sizeof(Field*)+
1438-
interval_count*sizeof(TYPELIB)+
1439-
share->table_check_constraints *
1440-
sizeof(Virtual_column_info*)+
1441-
(share->fields+interval_parts+
1442-
keys+3)*sizeof(char *)+
1443-
(n_length+int_length+com_length+
1444-
vcol_screen_length)))))
1445-
goto err; /* purecov: inspected */
1446-
1447-
share->field= field_ptr;
1444+
goto err;
1445+
1446+
field_ptr= share->field;
1447+
table_check_constraints= share->check_constraints;
14481448
read_length=(uint) (share->fields * field_pack_length +
14491449
pos+ (uint) (n_length+int_length+com_length+
14501450
vcol_screen_length));
14511451
strpos= disk_buff+pos;
14521452

1453-
share->intervals= (TYPELIB*) (field_ptr+share->fields+1);
1454-
share->check_constraints= ((Virtual_column_info**)
1455-
(share->intervals+interval_count));
1456-
table_check_constraints= share->check_constraints;
1457-
interval_array= (const char **) (table_check_constraints+
1458-
share->table_check_constraints);
1459-
names= (char*) (interval_array+share->fields+interval_parts+keys+3);
14601453
if (!interval_count)
14611454
share->intervals= 0; // For better debugging
1462-
memcpy((char*) names, strpos+(share->fields*field_pack_length),
1463-
(uint) (n_length+int_length));
1464-
comment_pos= names+(n_length+int_length);
1455+
1456+
memcpy(names, strpos+(share->fields*field_pack_length), n_length+int_length);
14651457
memcpy(comment_pos, disk_buff+read_length-com_length-vcol_screen_length,
14661458
com_length);
1467-
vcol_screen_pos= (uchar*) (names+(n_length+int_length+com_length));
14681459
memcpy(vcol_screen_pos, disk_buff+read_length-vcol_screen_length,
14691460
vcol_screen_length);
14701461

14711462
fix_type_pointers(&interval_array, &share->fieldnames, 1, &names);
14721463
if (share->fieldnames.count != share->fields)
14731464
goto err;
1474-
fix_type_pointers(&interval_array, share->intervals, interval_count,
1475-
&names);
1465+
fix_type_pointers(&interval_array, share->intervals, interval_count, &names);
14761466

14771467
{
14781468
/* Set ENUM and SET lengths */

0 commit comments

Comments
 (0)