Skip to content

Commit

Permalink
Merge pull request #644 from smuehlst/opj_aligned_malloc
Browse files Browse the repository at this point in the history
Avoid pointer arithmetic with (void *) pointers
  • Loading branch information
mayeut committed Oct 21, 2015
2 parents d48be27 + b7a1623 commit b06bed7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/openjp2/opj_malloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ static INLINE void *opj_aligned_realloc_n(void *ptr, size_t alignment, size_t ne
size_t new_offset;

/* realloc created a new copy, realign the copied memory block */
old_offset = (size_t)(ptr - oldmem);
old_offset = (size_t)((OPJ_UINT8*)ptr - (OPJ_UINT8*)oldmem);

/* offset = ((alignment + 1U) - ((size_t)(mem + sizeof(void*)) & alignment)) & alignment; */
/* Use the fact that alignment + 1U is a power of 2 */
Expand Down

0 comments on commit b06bed7

Please sign in to comment.