On Fri, Aug 22, 2008 at 6:41 PM, Tony Mechelynck wrote:
>
> On 22/08/08 21:20, Jan Minář wrote:
>>> Thanks.  I'll have a good look at it later.  One thing I noticed: you
>>> don't need to give an error message for running out of memory at this
>>> level, it's already done at a lower level in alloc().  There it also
>>
>> That's what I thought, too.  But vim_strsave_shellescape() is
>> documented to return NULL when out of memory:
>>
>> src/misc2.c:
>>
>>      1279  * Returns the result in allocated memory, NULL if we have run out.
>>      1280  */
>>      1281     char_u *
>>      1282 vim_strsave_shellescape(string, do_special)
>>
>> Cheers,
>> Jan.
>
> Well, if you have run out of memory, it's probably too late to allocate
> a new memory block in order to return an error message, isn't it?
>
> Best regards,
> Tony.

Yes, but...  in the case of the line in question:
printf("ERROR: out of memory\n");
Jan wasn't trying to dynamically allocate more memory from the heap;
he was printing out a string that was already allocated by the OS
before vim even reached its main() function.  In C, unlike in some
interpreted language like, IIRC, Python, all string literals are
loaded into memory before the program gets control, and any reference
to them is just a matter of dereferencing a pointer.

~Matt

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui