Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KQeWI-0004su-AO for qemu-devel@nongnu.org; Wed, 06 Aug 2008 04:37:22 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KQeWG-0004rD-N7 for qemu-devel@nongnu.org; Wed, 06 Aug 2008 04:37:21 -0400 Received: from [199.232.76.173] (port=45746 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KQeWG-0004qr-6D for qemu-devel@nongnu.org; Wed, 06 Aug 2008 04:37:20 -0400 Received: from savannah.gnu.org ([199.232.41.3]:53376 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KQeWF-0008VT-PK for qemu-devel@nongnu.org; Wed, 06 Aug 2008 04:37:19 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1KQeWE-0008U0-38 for qemu-devel@nongnu.org; Wed, 06 Aug 2008 08:37:18 +0000 Received: from ths by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1KQeWD-0008Tw-Oo for qemu-devel@nongnu.org; Wed, 06 Aug 2008 08:37:17 +0000 MIME-Version: 1.0 Errors-To: ths Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Thiemo Seufer Message-Id: Date: Wed, 06 Aug 2008 08:37:17 +0000 Subject: [Qemu-devel] [4986] Add qemu_realloc(), by Gerd Hoffmann. Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 4986 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4986 Author: ths Date: 2008-08-06 08:37:17 +0000 (Wed, 06 Aug 2008) Log Message: ----------- Add qemu_realloc(), by Gerd Hoffmann. Modified Paths: -------------- trunk/block-dmg.c trunk/block-vvfat.c trunk/hw/blizzard.c trunk/hw/lsi53c895a.c trunk/hw/rtl8139.c trunk/hw/soc_dma.c trunk/qemu-common.h trunk/qemu-malloc.c trunk/vnc.c Modified: trunk/block-dmg.c =================================================================== --- trunk/block-dmg.c 2008-08-03 19:04:11 UTC (rev 4985) +++ trunk/block-dmg.c 2008-08-06 08:37:17 UTC (rev 4986) @@ -125,11 +125,11 @@ goto dmg_close; chunk_count = (count-204)/40; new_size = sizeof(uint64_t) * (s->n_chunks + chunk_count); - s->types = realloc(s->types, new_size/2); - s->offsets = realloc(s->offsets, new_size); - s->lengths = realloc(s->lengths, new_size); - s->sectors = realloc(s->sectors, new_size); - s->sectorcounts = realloc(s->sectorcounts, new_size); + s->types = qemu_realloc(s->types, new_size/2); + s->offsets = qemu_realloc(s->offsets, new_size); + s->lengths = qemu_realloc(s->lengths, new_size); + s->sectors = qemu_realloc(s->sectors, new_size); + s->sectorcounts = qemu_realloc(s->sectorcounts, new_size); for(i=s->n_chunks;in_chunks+chunk_count;i++) { s->types[i] = read_uint32(s->fd); Modified: trunk/block-vvfat.c =================================================================== --- trunk/block-vvfat.c 2008-08-03 19:04:11 UTC (rev 4985) +++ trunk/block-vvfat.c 2008-08-06 08:37:17 UTC (rev 4986) @@ -101,7 +101,7 @@ { if((index + 1) * array->item_size > array->size) { int new_size = (index + 32) * array->item_size; - array->pointer = realloc(array->pointer, new_size); + array->pointer = qemu_realloc(array->pointer, new_size); if (!array->pointer) return -1; array->size = new_size; @@ -127,7 +127,7 @@ static inline void* array_insert(array_t* array,unsigned int index,unsigned int count) { if((array->next+count)*array->item_size>array->size) { int increment=count*array->item_size; - array->pointer=realloc(array->pointer,array->size+increment); + array->pointer=qemu_realloc(array->pointer,array->size+increment); if(!array->pointer) return 0; array->size+=increment; Modified: trunk/hw/blizzard.c =================================================================== --- trunk/hw/blizzard.c 2008-08-03 19:04:11 UTC (rev 4985) +++ trunk/hw/blizzard.c 2008-08-06 08:37:17 UTC (rev 4986) @@ -192,7 +192,7 @@ s->data.len = s->bpp * s->data.dx * s->data.dy; s->data.pitch = s->data.dx; if (s->data.len > s->data.buflen) { - s->data.buf = realloc(s->data.buf, s->data.len); + s->data.buf = qemu_realloc(s->data.buf, s->data.len); s->data.buflen = s->data.len; } s->data.ptr = s->data.buf; Modified: trunk/hw/lsi53c895a.c =================================================================== --- trunk/hw/lsi53c895a.c 2008-08-03 19:04:11 UTC (rev 4985) +++ trunk/hw/lsi53c895a.c 2008-08-06 08:37:17 UTC (rev 4986) @@ -501,7 +501,7 @@ DPRINTF("Queueing tag=0x%x\n", s->current_tag); if (s->queue_len == s->active_commands) { s->queue_len++; - s->queue = realloc(s->queue, s->queue_len * sizeof(lsi_queue)); + s->queue = qemu_realloc(s->queue, s->queue_len * sizeof(lsi_queue)); } p = &s->queue[s->active_commands++]; p->tag = s->current_tag; Modified: trunk/hw/rtl8139.c =================================================================== --- trunk/hw/rtl8139.c 2008-08-03 19:04:11 UTC (rev 4985) +++ trunk/hw/rtl8139.c 2008-08-06 08:37:17 UTC (rev 4986) @@ -2001,7 +2001,7 @@ while (s->cplus_txbuffer && s->cplus_txbuffer_offset + txsize >= s->cplus_txbuffer_len) { s->cplus_txbuffer_len += CP_TX_BUFFER_SIZE; - s->cplus_txbuffer = realloc(s->cplus_txbuffer, s->cplus_txbuffer_len); + s->cplus_txbuffer = qemu_realloc(s->cplus_txbuffer, s->cplus_txbuffer_len); DEBUG_PRINT(("RTL8139: +++ C+ mode transmission buffer space changed to %d\n", s->cplus_txbuffer_len)); } Modified: trunk/hw/soc_dma.c =================================================================== --- trunk/hw/soc_dma.c 2008-08-03 19:04:11 UTC (rev 4985) +++ trunk/hw/soc_dma.c 2008-08-06 08:37:17 UTC (rev 4986) @@ -50,7 +50,7 @@ void transfer_fifo2fifo(struct soc_dma_ch_s *ch) { if (ch->bytes > fifo_size) - fifo_buf = realloc(fifo_buf, fifo_size = ch->bytes); + fifo_buf = qemu_realloc(fifo_buf, fifo_size = ch->bytes); /* Implement as transfer_fifo2linear + transfer_linear2fifo. */ ch->io_fn[0](ch->io_opaque[0], fifo_buf, ch->bytes); @@ -262,7 +262,7 @@ struct memmap_entry_s *entry; struct dma_s *dma = (struct dma_s *) soc; - dma->memmap = realloc(dma->memmap, sizeof(*entry) * + dma->memmap = qemu_realloc(dma->memmap, sizeof(*entry) * (dma->memmap_size + 1)); entry = soc_dma_lookup(dma, virt_base); @@ -314,7 +314,7 @@ struct memmap_entry_s *entry; struct dma_s *dma = (struct dma_s *) soc; - dma->memmap = realloc(dma->memmap, sizeof(*entry) * + dma->memmap = qemu_realloc(dma->memmap, sizeof(*entry) * (dma->memmap_size + 1)); entry = soc_dma_lookup(dma, virt_base); Modified: trunk/qemu-common.h =================================================================== --- trunk/qemu-common.h 2008-08-03 19:04:11 UTC (rev 4985) +++ trunk/qemu-common.h 2008-08-06 08:37:17 UTC (rev 4986) @@ -87,6 +87,7 @@ time_t mktimegm(struct tm *tm); void *qemu_malloc(size_t size); +void *qemu_realloc(void *ptr, size_t size); void *qemu_mallocz(size_t size); void qemu_free(void *ptr); char *qemu_strdup(const char *str); Modified: trunk/qemu-malloc.c =================================================================== --- trunk/qemu-malloc.c 2008-08-03 19:04:11 UTC (rev 4985) +++ trunk/qemu-malloc.c 2008-08-06 08:37:17 UTC (rev 4986) @@ -38,6 +38,11 @@ return malloc(size); } +void *qemu_realloc(void *ptr, size_t size) +{ + return realloc(ptr, size); +} + void *qemu_mallocz(size_t size) { void *ptr; Modified: trunk/vnc.c =================================================================== --- trunk/vnc.c 2008-08-03 19:04:11 UTC (rev 4985) +++ trunk/vnc.c 2008-08-06 08:37:17 UTC (rev 4986) @@ -291,8 +291,8 @@ int size_changed; VncState *vs = ds->opaque; - ds->data = realloc(ds->data, w * h * vs->depth); - vs->old_data = realloc(vs->old_data, w * h * vs->depth); + ds->data = qemu_realloc(ds->data, w * h * vs->depth); + vs->old_data = qemu_realloc(vs->old_data, w * h * vs->depth); if (ds->data == NULL || vs->old_data == NULL) { fprintf(stderr, "vnc: memory allocation failed\n"); @@ -611,7 +611,7 @@ { if ((buffer->capacity - buffer->offset) < len) { buffer->capacity += (len + 1024); - buffer->buffer = realloc(buffer->buffer, buffer->capacity); + buffer->buffer = qemu_realloc(buffer->buffer, buffer->capacity); if (buffer->buffer == NULL) { fprintf(stderr, "vnc: out of memory\n"); exit(1);