Create local round up function for jmemmgr.c so we can revert the original argument types of jround_up() without breaking the build on 64-bit Windows.
This commit is contained in:
15
jmemmgr.c
15
jmemmgr.c
@@ -37,6 +37,15 @@ extern char * getenv JPP((const char * name));
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
LOCAL(size_t)
|
||||||
|
round_up_pow2 (size_t a, size_t b)
|
||||||
|
/* a rounded up to the next multiple of b, i.e. ceil(a/b)*b */
|
||||||
|
/* Assumes a >= 0, b > 0, and b is a power of 2 */
|
||||||
|
{
|
||||||
|
return ((a + b - 1) & (~(b - 1)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Some important notes:
|
* Some important notes:
|
||||||
* The allocation routines provided here must never return NULL.
|
* The allocation routines provided here must never return NULL.
|
||||||
@@ -265,7 +274,7 @@ alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
|||||||
* and so that algorithms can straddle outside the proper area up
|
* and so that algorithms can straddle outside the proper area up
|
||||||
* to the next alignment.
|
* to the next alignment.
|
||||||
*/
|
*/
|
||||||
sizeofobject = jround_up(sizeofobject, ALIGN_SIZE);
|
sizeofobject = round_up_pow2(sizeofobject, ALIGN_SIZE);
|
||||||
|
|
||||||
/* Check for unsatisfiable request (do now to ensure no overflow below) */
|
/* Check for unsatisfiable request (do now to ensure no overflow below) */
|
||||||
if ((SIZEOF(small_pool_hdr) + sizeofobject + ALIGN_SIZE - 1) > MAX_ALLOC_CHUNK)
|
if ((SIZEOF(small_pool_hdr) + sizeofobject + ALIGN_SIZE - 1) > MAX_ALLOC_CHUNK)
|
||||||
@@ -354,7 +363,7 @@ alloc_large (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
|||||||
* algorithms can straddle outside the proper area up to the next
|
* algorithms can straddle outside the proper area up to the next
|
||||||
* alignment.
|
* alignment.
|
||||||
*/
|
*/
|
||||||
sizeofobject = jround_up(sizeofobject, ALIGN_SIZE);
|
sizeofobject = round_up_pow2(sizeofobject, ALIGN_SIZE);
|
||||||
|
|
||||||
/* Check for unsatisfiable request (do now to ensure no overflow below) */
|
/* Check for unsatisfiable request (do now to ensure no overflow below) */
|
||||||
if ((SIZEOF(large_pool_hdr) + sizeofobject + ALIGN_SIZE - 1) > MAX_ALLOC_CHUNK)
|
if ((SIZEOF(large_pool_hdr) + sizeofobject + ALIGN_SIZE - 1) > MAX_ALLOC_CHUNK)
|
||||||
@@ -420,7 +429,7 @@ alloc_sarray (j_common_ptr cinfo, int pool_id,
|
|||||||
/* Make sure each row is properly aligned */
|
/* Make sure each row is properly aligned */
|
||||||
if ((ALIGN_SIZE % SIZEOF(JSAMPLE)) != 0)
|
if ((ALIGN_SIZE % SIZEOF(JSAMPLE)) != 0)
|
||||||
out_of_memory(cinfo, 5); /* safety check */
|
out_of_memory(cinfo, 5); /* safety check */
|
||||||
samplesperrow = (JDIMENSION)jround_up(samplesperrow, (2 * ALIGN_SIZE) / SIZEOF(JSAMPLE));
|
samplesperrow = (JDIMENSION)round_up_pow2(samplesperrow, (2 * ALIGN_SIZE) / SIZEOF(JSAMPLE));
|
||||||
|
|
||||||
/* Calculate max # of rows allowed in one allocation chunk */
|
/* Calculate max # of rows allowed in one allocation chunk */
|
||||||
ltemp = (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr)) /
|
ltemp = (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr)) /
|
||||||
|
|||||||
@@ -375,7 +375,7 @@ EXTERN(void) jinit_memory_mgr JPP((j_common_ptr cinfo));
|
|||||||
|
|
||||||
/* Utility routines in jutils.c */
|
/* Utility routines in jutils.c */
|
||||||
EXTERN(long) jdiv_round_up JPP((long a, long b));
|
EXTERN(long) jdiv_round_up JPP((long a, long b));
|
||||||
EXTERN(size_t) jround_up JPP((size_t a, size_t b));
|
EXTERN(long) jround_up JPP((long a, long b));
|
||||||
EXTERN(void) jcopy_sample_rows JPP((JSAMPARRAY input_array, int source_row,
|
EXTERN(void) jcopy_sample_rows JPP((JSAMPARRAY input_array, int source_row,
|
||||||
JSAMPARRAY output_array, int dest_row,
|
JSAMPARRAY output_array, int dest_row,
|
||||||
int num_rows, JDIMENSION num_cols));
|
int num_rows, JDIMENSION num_cols));
|
||||||
|
|||||||
4
jutils.c
4
jutils.c
@@ -77,8 +77,8 @@ jdiv_round_up (long a, long b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GLOBAL(size_t)
|
GLOBAL(long)
|
||||||
jround_up (size_t a, size_t b)
|
jround_up (long a, long b)
|
||||||
/* Compute a rounded up to next multiple of b, ie, ceil(a/b)*b */
|
/* Compute a rounded up to next multiple of b, ie, ceil(a/b)*b */
|
||||||
/* Assumes a >= 0, b > 0 */
|
/* Assumes a >= 0, b > 0 */
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user