diff options
Diffstat (limited to 'prism/util/pm_integer.h')
-rw-r--r-- | prism/util/pm_integer.h | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/prism/util/pm_integer.h b/prism/util/pm_integer.h index 63f560275d..7f172988b3 100644 --- a/prism/util/pm_integer.h +++ b/prism/util/pm_integer.h @@ -15,30 +15,25 @@ #include <stdlib.h> /** - * A node in the linked list of a pm_integer_t. + * A structure represents an arbitrary-sized integer. */ -typedef struct pm_integer_word { - /** A pointer to the next node in the list. */ - struct pm_integer_word *next; - - /** The value of the node. */ +typedef struct { + /** + * Embedded value for small integer. This value is set to 0 if the value + * does not fit into uint32_t. + */ uint32_t value; -} pm_integer_word_t; -/** - * This structure represents an arbitrary-sized integer. It is implemented as a - * linked list of 32-bit integers, with the least significant digit at the head - * of the list. - */ -typedef struct { - /** The number of nodes in the linked list that have been allocated. */ + /** + * The number of allocated values. length is set to 0 if the integer fits + * into uint32_t. + */ size_t length; /** - * The head of the linked list, embedded directly so that allocations do not - * need to be performed for small integers. + * List of 32-bit integers. Set to NULL if the integer fits into uint32_t. */ - pm_integer_word_t head; + uint32_t *values; /** * Whether or not the integer is negative. It is stored this way so that a |