qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [6466] Fix qemu_malloc.
@ 2009-01-28 17:16 malc
  2009-01-28 18:44 ` [Qemu-devel] PATCH: qemu_mallocz(): minus one function and replace calloc() instead malloc() Pavel Vasilyev
  0 siblings, 1 reply; 4+ messages in thread
From: malc @ 2009-01-28 17:16 UTC (permalink / raw)
  To: qemu-devel

Revision: 6466
          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6466
Author:   malc
Date:     2009-01-28 17:16:56 +0000 (Wed, 28 Jan 2009)

Log Message:
-----------
Fix qemu_malloc.

make {linux,bsd}-user qemu_realloc handle ptr == NULL correctly.
spotted by malc.

Modified Paths:
--------------
    trunk/bsd-user/mmap.c
    trunk/linux-user/mmap.c

Modified: trunk/bsd-user/mmap.c
===================================================================
--- trunk/bsd-user/mmap.c	2009-01-27 19:15:31 UTC (rev 6465)
+++ trunk/bsd-user/mmap.c	2009-01-28 17:16:56 UTC (rev 6466)
@@ -127,6 +127,8 @@
     size_t old_size, copy;
     void *new_ptr;
 
+    if (!ptr)
+        return qemu_malloc(size);
     old_size = *(size_t *)((char *)ptr - 16);
     copy = old_size < size ? old_size : size;
     new_ptr = qemu_malloc(size);

Modified: trunk/linux-user/mmap.c
===================================================================
--- trunk/linux-user/mmap.c	2009-01-27 19:15:31 UTC (rev 6465)
+++ trunk/linux-user/mmap.c	2009-01-28 17:16:56 UTC (rev 6466)
@@ -128,6 +128,8 @@
     size_t old_size, copy;
     void *new_ptr;
 
+    if (!ptr)
+        return qemu_malloc(size);
     old_size = *(size_t *)((char *)ptr - 16);
     copy = old_size < size ? old_size : size;
     new_ptr = qemu_malloc(size);

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Qemu-devel] PATCH: qemu_mallocz(): minus one function and replace calloc() instead malloc()
  2009-01-28 17:16 [Qemu-devel] [6466] Fix qemu_malloc malc
@ 2009-01-28 18:44 ` Pavel Vasilyev
  2009-01-28 19:33   ` Lionel Landwerlin
  0 siblings, 1 reply; 4+ messages in thread
From: Pavel Vasilyev @ 2009-01-28 18:44 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 330 bytes --]


 May be this better? 



--- qemu-malloc.c Base (BASE)
+++ qemu-malloc.c Locally Modified (Based On LOCAL)
@@ -46,10 +46,9 @@
 void *(size_t size)
 {
     void *ptr;
-    ptr = qemu_malloc(size);
+    ptr = calloc(1, size);
     if (!ptr)
         return NULL;
-    memset(ptr, 0, size);
     return ptr;
 }
 

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 194 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] PATCH: qemu_mallocz(): minus one function and replace calloc() instead malloc()
  2009-01-28 18:44 ` [Qemu-devel] PATCH: qemu_mallocz(): minus one function and replace calloc() instead malloc() Pavel Vasilyev
@ 2009-01-28 19:33   ` Lionel Landwerlin
  2009-01-28 20:00     ` malc
  0 siblings, 1 reply; 4+ messages in thread
From: Lionel Landwerlin @ 2009-01-28 19:33 UTC (permalink / raw)
  To: qemu-devel

Le mercredi 28 janvier 2009 à 21:44 +0300, Pavel Vasilyev a écrit :
> May be this better? 
> 
> 
> 
> --- qemu-malloc.c Base (BASE)
> +++ qemu-malloc.c Locally Modified (Based On LOCAL)
> @@ -46,10 +46,9 @@
>  void *(size_t size)
>  {
>      void *ptr;
> -    ptr = qemu_malloc(size);
> +    ptr = calloc(1, size);
>      if (!ptr)
>          return NULL;
> -    memset(ptr, 0, size);
>      return ptr;
>  }
>  

This is allocation in system emulation, Malc patch's was about user
emulation.

-- 
Lione Landwerlin                                         

O p e n W i d e                    14, rue Gaillon 75002 Paris

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] PATCH: qemu_mallocz(): minus one function and replace calloc() instead malloc()
  2009-01-28 19:33   ` Lionel Landwerlin
@ 2009-01-28 20:00     ` malc
  0 siblings, 0 replies; 4+ messages in thread
From: malc @ 2009-01-28 20:00 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1029 bytes --]

On Wed, 28 Jan 2009, Lionel Landwerlin wrote:

> Le mercredi 28 janvier 2009 ЪЪ 21:44 +0300, Pavel Vasilyev a ЪЪcrit :
> > May be this better? 
> > 
> > 
> > 
> > --- qemu-malloc.c Base (BASE)
> > +++ qemu-malloc.c Locally Modified (Based On LOCAL)
> > @@ -46,10 +46,9 @@
> >  void *(size_t size)
> >  {
> >      void *ptr;
> > -    ptr = qemu_malloc(size);
> > +    ptr = calloc(1, size);
> >      if (!ptr)
> >          return NULL;
> > -    memset(ptr, 0, size);
> >      return ptr;
> >  }
> >  
> 
> This is allocation in system emulation, Malc patch's was about user
> emulation.

It wasn't mine, it was Gerd Hoffmann, but his submission, while fine
enough for git, left the SVN commit without proper author attribution
(I normally wouldn't have 'spotted by malc' in the commit messages, so
 that was a good enough give away, that the patch wasn't mine)

Sorry Gerd, perhaps it's a good idea to add Signed-off-by lines after
all, if only to know who wrote what.

-- 
mailto:av1474@comtv.ru

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-01-28 20:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-28 17:16 [Qemu-devel] [6466] Fix qemu_malloc malc
2009-01-28 18:44 ` [Qemu-devel] PATCH: qemu_mallocz(): minus one function and replace calloc() instead malloc() Pavel Vasilyev
2009-01-28 19:33   ` Lionel Landwerlin
2009-01-28 20:00     ` malc

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).