1.1 --- a/templates/progops.c Fri Dec 02 18:31:20 2016 +0100
1.2 +++ b/templates/progops.c Fri Dec 02 21:16:06 2016 +0100
1.3 @@ -27,42 +27,39 @@
1.4 __fragment *__new_fragment(unsigned int n)
1.5 {
1.6 /* Allocate space for the list. */
1.7 +
1.8 __fragment *data = (__fragment *) __ALLOCATE(1, __FRAGMENT_SIZE(n));
1.9
1.10 /* The initial capacity is the same as the given size. */
1.11 +
1.12 data->size = 0;
1.13 data->capacity = n;
1.14 return data;
1.15 }
1.16
1.17 -static inline unsigned int __mapping_buckets(unsigned int n)
1.18 -{
1.19 - return n > 0 ? n / 2 : 5;
1.20 -}
1.21 -
1.22 __mapping *__new_mapping(unsigned int n)
1.23 {
1.24 /* Allocate a number of buckets. */
1.25 - unsigned int capacity = __mapping_buckets(n);
1.26 - __mapping *data = (__mapping *) __ALLOCATE(1, __MAPPING_SIZE(capacity));
1.27 +
1.28 + __mapping *data = (__mapping *) __ALLOCATE(1, __MAPPING_SIZE(n));
1.29 unsigned int i;
1.30
1.31 /* Create arrays for key and value buckets. */
1.32
1.33 - data->keys = (__fragment **) __ALLOCATE(capacity, sizeof(__fragment *));
1.34 - data->values = (__fragment **) __ALLOCATE(capacity, sizeof(__fragment *));
1.35 + data->keys = (__fragment **) __ALLOCATE(n, sizeof(__fragment *));
1.36 + data->values = (__fragment **) __ALLOCATE(n, sizeof(__fragment *));
1.37
1.38 /* Allocate fragments with an initial size of 2, assuming a mostly uniform
1.39 distribution of values across the buckets will occur. */
1.40
1.41 - for (i = 0; i < capacity; i++)
1.42 + for (i = 0; i < n; i++)
1.43 {
1.44 data->keys[i] = __new_fragment(2);
1.45 data->values[i] = __new_fragment(2);
1.46 }
1.47
1.48 data->size = 0;
1.49 - data->capacity = capacity;
1.50 + data->capacity = n;
1.51 return data;
1.52 }
1.53