File tree Expand file tree Collapse file tree 1 file changed +1
-8
lines changed
Expand file tree Collapse file tree 1 file changed +1
-8
lines changed Original file line number Diff line number Diff line change @@ -40,20 +40,13 @@ static R_INLINE size_t get_full_size(size_t n_elements, double load_factor) {
4040
4141static hashtab * hash_create_ (size_t n , double load_factor ) {
4242 size_t n_full = get_full_size (n , load_factor );
43- // precondition: sizeof hash_pair[n_full] < SIZE_MAX
44- // (note that sometimes n is 0)
45- if (n_full && sizeof (struct hash_pair ) >= SIZE_MAX / n_full )
46- internal_error (
47- __func__ , "n=%zu with load_factor=%g would overflow total allocation size" ,
48- n , load_factor
49- );
5043 hashtab * ret = (hashtab * )R_alloc (sizeof (hashtab ), 1 );
5144 ret -> size = n_full ;
5245 ret -> free = n ;
5346 // Multiply by size to get different hash functions when rehashing
5447 ret -> multiplier1 = n_full * hash_multiplier1 ;
5548 ret -> multiplier2 = n_full * hash_multiplier2 ;
56- ret -> table = (struct hash_pair * )R_alloc (sizeof ( struct hash_pair [ n_full ]), 1 );
49+ ret -> table = (struct hash_pair * )R_alloc (n_full , sizeof ( * ret -> table ) );
5750 // No valid SEXP is a null pointer, so it's a safe marker for empty cells.
5851 for (size_t i = 0 ; i < n_full ; ++ i ) {
5952 ret -> table [i ].key = NULL ;
You can’t perform that action at this time.
0 commit comments