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. On Tue, Feb 18, 2025 at 1:15 PM Paul Dufresne via Freedos-devel <freedos-devel@lists.sourceforge.net> wrote: > > Not evolving fast... > but I change FeeCOM shell/init.c to show cmdlen... > if((cmdline = malloc(cmdlen + 1)) == 0) { > printf("cmdlen=%d",cmdlen); > error_out_of_memory(); /* Cannot recover from this problem */ > return E_NoMem; > } > > And it now writes cmdlen=40 before the Out of memory error.... > suggesting there is no 40 bytes left for ... I believe this is the > parameters pass to command.com. > > So... where malloc get it's memory from? If it would be from EMS memory > it could explain why JemmEX NoEMS could cause the problem... _______________________________________________ Freedos-devel mailing list Freedos-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/freedos-devel