Skip to content

Commit 8cd7fe9

Browse files
author
Steinar H. Gunderson
committed
Bug #25950778: REMOVE POINTER ARITHMETIC MACROS
Remove the unneeded macros ADD_TO_PTR and PTR_BYTE_DIFF. Change-Id: I2a49542de36c62f19bdaf232651293cc60c4c394
1 parent 54e4bba commit 8cd7fe9

File tree

5 files changed

+10
-19
lines changed

5 files changed

+10
-19
lines changed

client/mysqltest.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11763,10 +11763,9 @@ int insert_pointer_name(POINTER_ARRAY *pa,char * name)
1176311763
DBUG_RETURN(1);
1176411764
if (new_pos != pa->str)
1176511765
{
11766-
my_ptrdiff_t diff=PTR_BYTE_DIFF(new_pos,pa->str);
11766+
ptrdiff_t diff= new_pos - pa->str;
1176711767
for (i=0 ; i < pa->typelib.count ; i++)
11768-
pa->typelib.type_names[i]= ADD_TO_PTR(pa->typelib.type_names[i],diff,
11769-
char*);
11768+
pa->typelib.type_names[i]= pa->typelib.type_names[i] + diff;
1177011769
pa->str=new_pos;
1177111770
}
1177211771
pa->max_length= pa->length+length+PS_MALLOC;

include/my_pointer_arithmetic.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -23,12 +23,7 @@
2323
of buffers to a given size.
2424
*/
2525

26-
#include "my_inttypes.h"
27-
2826
#define MY_ALIGN(A,L) (((A) + (L) - 1) & ~((L) - 1))
2927
#define ALIGN_SIZE(A) MY_ALIGN((A),sizeof(double))
30-
/* Size to make adressable obj. */
31-
#define ADD_TO_PTR(ptr,size,type) (type) ((uchar*) (ptr)+size)
32-
#define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((uchar*) (A) - (uchar*) (B))
3328

3429
#endif // MY_POINTER_ARITHMETIC_INCLUDED

mysys/mf_keycache.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1856,9 +1856,7 @@ static BLOCK_LINK *find_key_block(KEY_CACHE *keycache,
18561856
block= &keycache->block_root[keycache->blocks_used];
18571857
block_mem_offset=
18581858
((size_t) keycache->blocks_used) * keycache->key_cache_block_size;
1859-
block->buffer= ADD_TO_PTR(keycache->block_mem,
1860-
block_mem_offset,
1861-
uchar*);
1859+
block->buffer= keycache->block_mem + block_mem_offset;
18621860
keycache->blocks_used++;
18631861
DBUG_ASSERT(!block->next_used);
18641862
}

sql/field.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,9 +1377,9 @@ class Field: public Proto_field, public Sql_alloc
13771377

13781378
virtual void move_field_offset(my_ptrdiff_t ptr_diff)
13791379
{
1380-
ptr= ADD_TO_PTR(ptr, ptr_diff, uchar*);
1380+
ptr+= ptr_diff;
13811381
if (real_maybe_null())
1382-
m_null_ptr= ADD_TO_PTR(m_null_ptr, ptr_diff, uchar*);
1382+
m_null_ptr+= ptr_diff;
13831383
}
13841384

13851385
virtual void get_image(uchar *buff, size_t length, const CHARSET_INFO*)
@@ -3910,7 +3910,7 @@ class Field_blob :public Field_longstr {
39103910
}
39113911
void set_ptr_offset(my_ptrdiff_t ptr_diff, uint32 length, uchar *data)
39123912
{
3913-
uchar *ptr_ofs= ADD_TO_PTR(ptr,ptr_diff,uchar*);
3913+
uchar *ptr_ofs= ptr + ptr_diff;
39143914
store_length(ptr_ofs, packlength, length);
39153915
memcpy(ptr_ofs+packlength, &data, sizeof(char*));
39163916
}
@@ -4433,7 +4433,7 @@ class Field_bit :public Field {
44334433
void move_field_offset(my_ptrdiff_t ptr_diff)
44344434
{
44354435
Field::move_field_offset(ptr_diff);
4436-
bit_ptr= ADD_TO_PTR(bit_ptr, ptr_diff, uchar*);
4436+
bit_ptr+= ptr_diff;
44374437
}
44384438
void hash(ulong *nr, ulong *nr2);
44394439
Field_bit *clone(MEM_ROOT *mem_root) const {

storage/myisam/mi_packrec.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,10 @@ bool _mi_read_pack_info(MI_INFO *info, bool fix_keys)
277277
MYF(MY_HOLD_ON_ERROR));
278278
/* Fix the table addresses in the tree heads. */
279279
{
280-
my_ptrdiff_t diff=PTR_BYTE_DIFF(decode_table,share->decode_tables);
280+
ptrdiff_t diff= decode_table - share->decode_tables;
281281
share->decode_tables=decode_table;
282282
for (i=0 ; i < trees ; i++)
283-
share->decode_trees[i].table=ADD_TO_PTR(share->decode_trees[i].table,
284-
diff, uint16*);
283+
share->decode_trees[i].table= share->decode_trees[i].table + diff;
285284
}
286285

287286
/* Fix record-ref-length for keys */

0 commit comments

Comments
 (0)