On Sat, 8 Mar 2014 14:09:17 -0500
Richard Hipp <d...@sqlite.org> wrote:


> It isn't really running out of memory....
> 
> The implementation of char() allocates 4 bytes of output buffer for
> each input character, which is sufficient to hold any valid unicode
> codepoint. But with zero input characters, that means it tries to
> allocate a zero-byte output buffer.  sqlite3_malloc() returns NULL
> when asked to allocate zero bytes, at which point the char()
> implementation thinks that the malloc() failed and reports the
> output-of-memory error.

It's OS dependant. From malloc FreeBSD man page, malloc.conf/_malloc_options, V 
option means:

 V       Attempting to allocate zero bytes will return a NULL pointer
         instead of a valid pointer.  (The default behavior is to make a
         minimal allocation and return a pointer to it.)  This option is
         provided for System V compatibility.  This option is incompatible
         with the ``X'' option.

> 
> The fix is to allocate 4*N+1 bytes instead of 4*N bytes.  Dan is
> checking in the fix even as I type this reply.
> 
> 
> -- 
> D. Richard Hipp
> d...@sqlite.org

---   ---
Eduardo Morras <emorr...@yahoo.es>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to