2009-07-13 Pavel Roskin <proski@gnu.org>
* kern/device.c (grub_device_iterate): Change struct part_ent to hold the name, not a pointer to it. Use one grub_malloc() per partition, not two. Free partition_name if grub_malloc() fails. Set ents to NULL only before grub_partition_iterate() is called.
This commit is contained in:
parent
75c59f59e7
commit
2df32b2c4a
2 changed files with 12 additions and 11 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2009-07-13 Pavel Roskin <proski@gnu.org>
|
||||||
|
|
||||||
|
* kern/device.c (grub_device_iterate): Change struct part_ent to
|
||||||
|
hold the name, not a pointer to it. Use one grub_malloc() per
|
||||||
|
partition, not two. Free partition_name if grub_malloc() fails.
|
||||||
|
Set ents to NULL only before grub_partition_iterate() is called.
|
||||||
|
|
||||||
2009-07-11 Bean <bean123ch@gmail.com>
|
2009-07-11 Bean <bean123ch@gmail.com>
|
||||||
|
|
||||||
* kern/ieee1275/openfw.c (grub_children_iterate): Fix size of
|
* kern/ieee1275/openfw.c (grub_children_iterate): Fix size of
|
||||||
|
|
|
@ -86,8 +86,8 @@ grub_device_iterate (int (*hook) (const char *name))
|
||||||
struct part_ent
|
struct part_ent
|
||||||
{
|
{
|
||||||
struct part_ent *next;
|
struct part_ent *next;
|
||||||
char *name;
|
char name[0];
|
||||||
} *ents = NULL;
|
} *ents;
|
||||||
|
|
||||||
int iterate_disk (const char *disk_name)
|
int iterate_disk (const char *disk_name)
|
||||||
{
|
{
|
||||||
|
@ -105,18 +105,17 @@ grub_device_iterate (int (*hook) (const char *name))
|
||||||
struct part_ent *p;
|
struct part_ent *p;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
ents = NULL;
|
||||||
(void) grub_partition_iterate (dev->disk, iterate_partition);
|
(void) grub_partition_iterate (dev->disk, iterate_partition);
|
||||||
grub_device_close (dev);
|
grub_device_close (dev);
|
||||||
|
|
||||||
p = ents;
|
p = ents;
|
||||||
ents = NULL;
|
|
||||||
while (p != NULL)
|
while (p != NULL)
|
||||||
{
|
{
|
||||||
struct part_ent *next = p->next;
|
struct part_ent *next = p->next;
|
||||||
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
ret = hook (p->name);
|
ret = hook (p->name);
|
||||||
grub_free (p->name);
|
|
||||||
grub_free (p);
|
grub_free (p);
|
||||||
p = next;
|
p = next;
|
||||||
}
|
}
|
||||||
|
@ -137,15 +136,10 @@ grub_device_iterate (int (*hook) (const char *name))
|
||||||
if (! partition_name)
|
if (! partition_name)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
p = grub_malloc (sizeof (*p));
|
p = grub_malloc (sizeof (p->next) + grub_strlen (disk->name) + 1 +
|
||||||
|
grub_strlen (partition_name) + 1);
|
||||||
if (!p)
|
if (!p)
|
||||||
return 1;
|
|
||||||
|
|
||||||
p->name = grub_malloc (grub_strlen (disk->name) + 1
|
|
||||||
+ grub_strlen (partition_name) + 1);
|
|
||||||
if (! p->name)
|
|
||||||
{
|
{
|
||||||
grub_free (p);
|
|
||||||
grub_free (partition_name);
|
grub_free (partition_name);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue