[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] read command
From: |
Robert Millan |
Subject: |
Re: [PATCH] read command |
Date: |
Fri, 1 Feb 2008 23:48:00 +0100 |
User-agent: |
Mutt/1.5.13 (2006-08-11) |
On Fri, Feb 01, 2008 at 11:45:50PM +0100, Robert Millan wrote:
> +static void *
> +grub_xrealloc (void *ptr, grub_size_t size)
> +{
> + void *value = grub_realloc (ptr, size);
> + if (value == 0)
> + grub_fatal ("Virtual memory exhausted");
> + return value;
> +}
> +
> +static char *
> +grub_getline (void)
> +{
> + int i;
> + char *line;
> +
> + i = 0;
> + line = grub_malloc (1 + i + sizeof('\0'));
> +
> + while ((line[i - 1] != '\n') && (line[i - 1] != '\r'))
> + {
> + line[i] = grub_getkey ();
> + if (grub_isprint (line[i]))
> + grub_putchar (line[i]);
> + i++;
> + line = grub_xrealloc (line, 1 + i + sizeof('\0'));
> + }
> + line[i] = '\0';
> +
> + return line;
> +}
Does it make sense to move any of these two to kernel? Or to normal.mod ? Or
maybe just to un-static-ize them and leave them here?
--
Robert Millan
<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)