OLD | NEW |
1 /***************************************************************************/ | 1 /***************************************************************************/ |
2 /* */ | 2 /* */ |
3 /* cf2arrst.c */ | 3 /* cf2arrst.c */ |
4 /* */ | 4 /* */ |
5 /* Adobe's code for Array Stacks (body). */ | 5 /* Adobe's code for Array Stacks (body). */ |
6 /* */ | 6 /* */ |
7 /* Copyright 2007-2013 Adobe Systems Incorporated. */ | 7 /* Copyright 2007-2013 Adobe Systems Incorporated. */ |
8 /* */ | 8 /* */ |
9 /* This software, and all works of authorship, whether in source or */ | 9 /* This software, and all works of authorship, whether in source or */ |
10 /* object code form as indicated by the copyright notice(s) included */ | 10 /* object code form as indicated by the copyright notice(s) included */ |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 static FT_Bool | 94 static FT_Bool |
95 cf2_arrstack_setNumElements( CF2_ArrStack arrstack, | 95 cf2_arrstack_setNumElements( CF2_ArrStack arrstack, |
96 size_t numElements ) | 96 size_t numElements ) |
97 { | 97 { |
98 FT_ASSERT( arrstack != NULL ); | 98 FT_ASSERT( arrstack != NULL ); |
99 | 99 |
100 { | 100 { |
101 FT_Error error = FT_Err_Ok; /* for FT_REALLOC */ | 101 FT_Error error = FT_Err_Ok; /* for FT_REALLOC */ |
102 FT_Memory memory = arrstack->memory; /* for FT_REALLOC */ | 102 FT_Memory memory = arrstack->memory; /* for FT_REALLOC */ |
103 | 103 |
104 FT_Long newSize = (FT_Long)( numElements * arrstack->sizeItem ); | 104 size_t newSize = numElements * arrstack->sizeItem; |
105 | 105 |
106 | 106 |
107 if ( numElements > LONG_MAX / arrstack->sizeItem ) | 107 if ( numElements > FT_LONG_MAX / arrstack->sizeItem ) |
108 goto exit; | 108 goto exit; |
109 | 109 |
110 | 110 |
111 FT_ASSERT( newSize > 0 ); /* avoid realloc with zero size */ | 111 FT_ASSERT( newSize > 0 ); /* avoid realloc with zero size */ |
112 | 112 |
113 if ( !FT_REALLOC( arrstack->ptr, arrstack->totalSize, newSize ) ) | 113 if ( !FT_REALLOC( arrstack->ptr, arrstack->totalSize, newSize ) ) |
114 { | 114 { |
115 arrstack->allocated = numElements; | 115 arrstack->allocated = numElements; |
116 arrstack->totalSize = newSize; | 116 arrstack->totalSize = newSize; |
117 | 117 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 void* newPtr = (FT_Byte*)arrstack->ptr + offset; | 232 void* newPtr = (FT_Byte*)arrstack->ptr + offset; |
233 | 233 |
234 | 234 |
235 FT_MEM_COPY( newPtr, ptr, arrstack->sizeItem ); | 235 FT_MEM_COPY( newPtr, ptr, arrstack->sizeItem ); |
236 arrstack->count += 1; | 236 arrstack->count += 1; |
237 } | 237 } |
238 } | 238 } |
239 | 239 |
240 | 240 |
241 /* END */ | 241 /* END */ |
OLD | NEW |