---- Le mar., 18 févr. 2025 14:31:04 -0500 Jim Hall via Freedos-devel  a écrit 
----

> I don't understand this code question, so I'll try to unwind it.
>
> 'malloc' allocates memory of size_t size, and returns a pointer to the
> allocated memory .. or NULL if it could not allocate the memory.
>
> I didn't look at the shell/init.c code for what kind of variable
> 'cmdline' is, but I assume it's a pointer? If 'cmdlen' is the number
> of characters you want to allocate (let's say cmdlen=40) then you
> should use:
>
> cmdline = malloc( sizeof(char) * (cmdlen+1) );
>
>
> Having called 'malloc' to get the memory, you should test it like this:
>
> if (cmdline == NULL) {
>  /* out of memory */
>  error_out_of_memory();
>  return E_NoMem;
> }
>
> After that test, you can assume cmdline has a valid pointer to enough
> memory to store the 40 characters.
>

I was more like saying... there is not enough memory left to allocate the 
command.com command line
that is about 40 bytes...
So the question is how could I explain there is not enough memory...
the under question is malloc (specifically in the shell code) take it's memory 
from which pool of memory?



_______________________________________________
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel

Reply via email to