qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] HACKING: clarify allocation/free recommendations
@ 2011-12-15 13:33 Peter Maydell
  2011-12-15 13:55 ` Stefan Hajnoczi
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Peter Maydell @ 2011-12-15 13:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Kevin Wolf, Stefan Hajnoczi, patches

Clarify the allocation/free recommendations; this is mostly
just tidying up following the global-search-and-replace done
with the conversion to the GLib g_malloc and friends.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 HACKING |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/HACKING b/HACKING
index 733eab2..471cf1d 100644
--- a/HACKING
+++ b/HACKING
@@ -77,11 +77,13 @@ avoided.
 
 Use of the malloc/free/realloc/calloc/valloc/memalign/posix_memalign
 APIs is not allowed in the QEMU codebase. Instead of these routines,
-use the replacement g_malloc/g_malloc0/g_realloc/g_free or
-qemu_vmalloc/qemu_memalign/qemu_vfree APIs.
+use the GLib memory allocation routines g_malloc/g_malloc0/g_new/
+g_new0/g_realloc/g_free or QEMU's qemu_vmalloc/qemu_memalign/qemu_vfree
+APIs.
 
-Please note that NULL check for the g_malloc result is redundant and
-that g_malloc() call with zero size is not allowed.
+Please note that g_malloc will exit on allocation failure, so there
+is no need to test for failure (as you would have to with malloc).
+Calling g_malloc with a zero size is valid and will return NULL.
 
 Memory allocated by qemu_vmalloc or qemu_memalign must be freed with
 qemu_vfree, since breaking this will cause problems on Win32 and user
-- 
1.7.5.4

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

* Re: [Qemu-devel] [PATCH] HACKING: clarify allocation/free recommendations
  2011-12-15 13:33 [Qemu-devel] [PATCH] HACKING: clarify allocation/free recommendations Peter Maydell
@ 2011-12-15 13:55 ` Stefan Hajnoczi
  2011-12-15 18:11 ` Anthony Liguori
  2011-12-15 18:12 ` Anthony Liguori
  2 siblings, 0 replies; 4+ messages in thread
From: Stefan Hajnoczi @ 2011-12-15 13:55 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-trivial, Kevin Wolf, qemu-devel, patches

On Thu, Dec 15, 2011 at 1:33 PM, Peter Maydell <peter.maydell@linaro.org> wrote:
> Clarify the allocation/free recommendations; this is mostly
> just tidying up following the global-search-and-replace done
> with the conversion to the GLib g_malloc and friends.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  HACKING |   10 ++++++----
>  1 files changed, 6 insertions(+), 4 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>

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

* Re: [Qemu-devel] [PATCH] HACKING: clarify allocation/free recommendations
  2011-12-15 13:33 [Qemu-devel] [PATCH] HACKING: clarify allocation/free recommendations Peter Maydell
  2011-12-15 13:55 ` Stefan Hajnoczi
@ 2011-12-15 18:11 ` Anthony Liguori
  2011-12-15 18:12 ` Anthony Liguori
  2 siblings, 0 replies; 4+ messages in thread
From: Anthony Liguori @ 2011-12-15 18:11 UTC (permalink / raw)
  To: Peter Maydell
  Cc: qemu-trivial, Kevin Wolf, patches, qemu-devel, Stefan Hajnoczi

On 12/15/2011 07:33 AM, Peter Maydell wrote:
> Clarify the allocation/free recommendations; this is mostly
> just tidying up following the global-search-and-replace done
> with the conversion to the GLib g_malloc and friends.
>
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>

Applied.  Thanks.

Regards,

Anthony Liguori

> ---
>   HACKING |   10 ++++++----
>   1 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/HACKING b/HACKING
> index 733eab2..471cf1d 100644
> --- a/HACKING
> +++ b/HACKING
> @@ -77,11 +77,13 @@ avoided.
>
>   Use of the malloc/free/realloc/calloc/valloc/memalign/posix_memalign
>   APIs is not allowed in the QEMU codebase. Instead of these routines,
> -use the replacement g_malloc/g_malloc0/g_realloc/g_free or
> -qemu_vmalloc/qemu_memalign/qemu_vfree APIs.
> +use the GLib memory allocation routines g_malloc/g_malloc0/g_new/
> +g_new0/g_realloc/g_free or QEMU's qemu_vmalloc/qemu_memalign/qemu_vfree
> +APIs.
>
> -Please note that NULL check for the g_malloc result is redundant and
> -that g_malloc() call with zero size is not allowed.
> +Please note that g_malloc will exit on allocation failure, so there
> +is no need to test for failure (as you would have to with malloc).
> +Calling g_malloc with a zero size is valid and will return NULL.
>
>   Memory allocated by qemu_vmalloc or qemu_memalign must be freed with
>   qemu_vfree, since breaking this will cause problems on Win32 and user

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

* Re: [Qemu-devel] [PATCH] HACKING: clarify allocation/free recommendations
  2011-12-15 13:33 [Qemu-devel] [PATCH] HACKING: clarify allocation/free recommendations Peter Maydell
  2011-12-15 13:55 ` Stefan Hajnoczi
  2011-12-15 18:11 ` Anthony Liguori
@ 2011-12-15 18:12 ` Anthony Liguori
  2 siblings, 0 replies; 4+ messages in thread
From: Anthony Liguori @ 2011-12-15 18:12 UTC (permalink / raw)
  To: Peter Maydell
  Cc: qemu-trivial, Kevin Wolf, patches, qemu-devel, Stefan Hajnoczi

On 12/15/2011 07:33 AM, Peter Maydell wrote:
> Clarify the allocation/free recommendations; this is mostly
> just tidying up following the global-search-and-replace done
> with the conversion to the GLib g_malloc and friends.
>
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>

Applied.  Thanks.

Regards,

Anthony Liguori

> ---
>   HACKING |   10 ++++++----
>   1 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/HACKING b/HACKING
> index 733eab2..471cf1d 100644
> --- a/HACKING
> +++ b/HACKING
> @@ -77,11 +77,13 @@ avoided.
>
>   Use of the malloc/free/realloc/calloc/valloc/memalign/posix_memalign
>   APIs is not allowed in the QEMU codebase. Instead of these routines,
> -use the replacement g_malloc/g_malloc0/g_realloc/g_free or
> -qemu_vmalloc/qemu_memalign/qemu_vfree APIs.
> +use the GLib memory allocation routines g_malloc/g_malloc0/g_new/
> +g_new0/g_realloc/g_free or QEMU's qemu_vmalloc/qemu_memalign/qemu_vfree
> +APIs.
>
> -Please note that NULL check for the g_malloc result is redundant and
> -that g_malloc() call with zero size is not allowed.
> +Please note that g_malloc will exit on allocation failure, so there
> +is no need to test for failure (as you would have to with malloc).
> +Calling g_malloc with a zero size is valid and will return NULL.
>
>   Memory allocated by qemu_vmalloc or qemu_memalign must be freed with
>   qemu_vfree, since breaking this will cause problems on Win32 and user

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

end of thread, other threads:[~2011-12-15 18:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-15 13:33 [Qemu-devel] [PATCH] HACKING: clarify allocation/free recommendations Peter Maydell
2011-12-15 13:55 ` Stefan Hajnoczi
2011-12-15 18:11 ` Anthony Liguori
2011-12-15 18:12 ` Anthony Liguori

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).