path: root/com32/lib
diff options
authorH. Peter Anvin <hpa@zytor.com>2008-04-09 10:49:51 -0700
committerH. Peter Anvin <hpa@zytor.com>2008-04-09 10:49:51 -0700
commit8c7e976621b91708272ca3e02a25e99155bc2da8 (patch)
treeb334b3dff239b9e9221c42b440351ce24fffc64a /com32/lib
parent44a89abc22caf7534ca25dbdbcc6a18b0296b751 (diff)
zonelist.c: Fix the coalescing of identical ranges
The old code could fail to coalesce backwards in the case where a range is totally obliterated. For now, just scan the whole list.
Diffstat (limited to 'com32/lib')
1 files changed, 6 insertions, 7 deletions
diff --git a/com32/lib/syslinux/zonelist.c b/com32/lib/syslinux/zonelist.c
index 44cec3f8..62b1cf3e 100644
--- a/com32/lib/syslinux/zonelist.c
+++ b/com32/lib/syslinux/zonelist.c
@@ -76,7 +76,7 @@ int syslinux_add_memmap(struct syslinux_memmap **list,
addr_t last;
struct syslinux_memmap *mp, **mpp;
- struct syslinux_memmap *mpi, **mppi;
+ struct syslinux_memmap *mpi;
struct syslinux_memmap *range;
enum syslinux_memmap_types oldtype;
@@ -94,9 +94,6 @@ int syslinux_add_memmap(struct syslinux_memmap **list,
mpp = &mp->next;
- /* Remember where we started messing with things. */
- mppi = mpp;
if (start < mp->start || mp->type == SMT_END) {
range = malloc(sizeof(*range));
if (!range)
@@ -129,9 +126,11 @@ int syslinux_add_memmap(struct syslinux_memmap **list,
/* Now the map is correct, but quite possibly not optimal. Scan the
map for ranges which are redundant and remove them. This is
technically excessive, since we scan the list to the end even
- though only part of it could have changed. Eventually we might
- care enough to save an end pointer from the operation above. */
- mpi = *mppi;
+ though only part of it could have changed. In particular, the first
+ entry that could change is one earlier than the first one changed
+ above, and once we stop changing things, there shouldn't be any
+ more changes. */
+ mpi = *list;
while (mpi->type != SMT_END) {
mp = mpi->next;
if (mpi->type == mp->type) {