diff options
author | Ramsay Jones <ramsay@ramsay1.demon.co.uk> | 2013-07-27 20:00:07 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-07-29 08:44:29 -0700 |
commit | d7a1d629c3be95f8c2ddd1973b9dae9dd893048f (patch) | |
tree | 274b2c158232a44c83d1614d7b79e4d63b2185c2 /Documentation/RelNotes/1.7.10.txt | |
parent | commit-slab: introduce a macro to define a slab for new type (diff) | |
download | tgif-d7a1d629c3be95f8c2ddd1973b9dae9dd893048f.tar.xz |
commit-slab.h: Fix memory allocation and addressing
The slab initialization code includes the calculation of the
slab 'elem_size', which is in turn used to determine the size
(capacity) of the slab. Each element of the slab represents an
array, of length 'stride', of 'elemtype'. (Note that it may be
clearer if the define_commit_slab macro parameter was called
'basetype' rather than 'elemtype'). However, the 'elem_size'
calculation incorrectly uses 'sizeof(struct slabname)' in the
expression, rather than 'sizeof(elemtype)'.
Within the slab access routine, <slabname>_at(), the given commit
'index' is transformed into an (slab#, slot#) pair used to address
the required element (a pointer to the first element of the array
of 'elemtype' associated with that commit). The current code to
calculate these address coordinates multiplies the commit index
by the 'stride' which, at least for the slab#, produces the wrong
result. Using the commit index directly, without scaling by the
'stride', produces the correct 'logical' address.
Also, when allocating a new slab, the size of the allocation only
allows for a slab containing elements of single element arrays of
'elemtype'. This should allow for elements of an array of length
'stride' of 'elemtype'. In order to fix this, we need to change
the element size parameter to xcalloc() by multiplying the current
element size (sizeof(**s->slab)) by the s->stride.
Having changed the calculation of the slot#, we now need to convert
the logical 'nth_slot', by scaling with s->stride, into the correct
physical address.
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'Documentation/RelNotes/1.7.10.txt')
0 files changed, 0 insertions, 0 deletions