Mercurial > hg
diff mcabber/src/hbuf.c @ 153:ae0844311710
[/trunk] Changeset 165 by mikael
* Do check on memory allocation for important data.
* Decrease scr_LogPrint buffer size to 1kb.
author | mikael |
---|---|
date | Sun, 01 May 2005 04:42:07 +0000 |
parents | 5647381a7dfb |
children | f7b03201877a |
line wrap: on
line diff
--- a/mcabber/src/hbuf.c Sun May 01 04:05:40 2005 +0000 +++ b/mcabber/src/hbuf.c Sun May 01 04:42:07 2005 +0000 @@ -61,7 +61,9 @@ if (prefix) strncpy(hbuf_block_elt->persist.prefix, prefix, PREFIX_LENGTH-1); if (!hbuf) { - hbuf_block_elt->ptr = g_new(char, HBB_BLOCKSIZE); + do { + hbuf_block_elt->ptr = g_new(char, HBB_BLOCKSIZE); + } while (!hbuf_block_elt->ptr); hbuf_block_elt->flags = HBB_FLAG_ALLOC | HBB_FLAG_PERSISTENT; hbuf_block_elt->persist.ptr_end_alloc = hbuf_block_elt->ptr + HBB_BLOCKSIZE; *p_hbuf = g_list_append(*p_hbuf, hbuf_block_elt); @@ -79,7 +81,9 @@ } if (hbuf_block_elt->ptr + strlen(text) >= hbuf_block_elt->persist.ptr_end_alloc) { // Too long for the current allocated bloc, we need another one - hbuf_block_elt->ptr = g_new0(char, HBB_BLOCKSIZE); + do { + hbuf_block_elt->ptr = g_new0(char, HBB_BLOCKSIZE); + } while (!hbuf_block_elt->ptr); hbuf_block_elt->flags = HBB_FLAG_ALLOC | HBB_FLAG_PERSISTENT; hbuf_block_elt->persist.ptr_end_alloc = hbuf_block_elt->ptr + HBB_BLOCKSIZE; }