* [Qemu-devel] [PATCH 3/5] HACKING: add memory management rules
@ 2010-08-15 17:50 Blue Swirl
0 siblings, 0 replies; 3+ messages in thread
From: Blue Swirl @ 2010-08-15 17:50 UTC (permalink / raw)
To: qemu-devel
Add memory management rules, somewhat like libvirt HACKING.
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
---
HACKING | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/HACKING b/HACKING
index 7c6b49e..e0342df 100644
--- a/HACKING
+++ b/HACKING
@@ -68,3 +68,14 @@ it points to, or it is aliased to another pointer that is.
2.3. Typedefs
Typedefs are used to eliminate the redundant 'struct' keyword.
+
+3. Low level memory management
+
+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 qemu_malloc/qemu_mallocz/qemu_realloc/qemu_free or
+qemu_vmalloc/qemu_memalign/qemu_vfree APIs.
+
+Memory allocated by qemu_vmalloc or qemu_memalign must be freed with
+qemu_vfree, since breaking this will cause problems on Win32 and user
+emulators.
--
1.6.2.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [Qemu-devel] [PATCH 3/5] HACKING: add memory management rules
@ 2010-08-26 18:38 Blue Swirl
2010-08-27 8:45 ` Kevin Wolf
0 siblings, 1 reply; 3+ messages in thread
From: Blue Swirl @ 2010-08-26 18:38 UTC (permalink / raw)
To: qemu-devel
Add memory management rules, somewhat like libvirt HACKING.
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
---
HACKING | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/HACKING b/HACKING
index 19fc874..554009e 100644
--- a/HACKING
+++ b/HACKING
@@ -72,3 +72,14 @@ Typedefs are used to eliminate the redundant
'struct' keyword.
2.4. Reserved namespaces in C
Underscore capital, double underscore, and underscore 't' suffixes should be
avoided.
+
+3. Low level memory management
+
+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 qemu_malloc/qemu_mallocz/qemu_realloc/qemu_free or
+qemu_vmalloc/qemu_memalign/qemu_vfree APIs.
+
+Memory allocated by qemu_vmalloc or qemu_memalign must be freed with
+qemu_vfree, since breaking this will cause problems on Win32 and user
+emulators.
--
1.6.2.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH 3/5] HACKING: add memory management rules
2010-08-26 18:38 [Qemu-devel] [PATCH 3/5] HACKING: add memory management rules Blue Swirl
@ 2010-08-27 8:45 ` Kevin Wolf
0 siblings, 0 replies; 3+ messages in thread
From: Kevin Wolf @ 2010-08-27 8:45 UTC (permalink / raw)
To: Blue Swirl; +Cc: qemu-devel
Am 26.08.2010 20:38, schrieb Blue Swirl:
> Add memory management rules, somewhat like libvirt HACKING.
>
> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
> ---
> HACKING | 11 +++++++++++
> 1 files changed, 11 insertions(+), 0 deletions(-)
>
> diff --git a/HACKING b/HACKING
> index 19fc874..554009e 100644
> --- a/HACKING
> +++ b/HACKING
> @@ -72,3 +72,14 @@ Typedefs are used to eliminate the redundant
> 'struct' keyword.
> 2.4. Reserved namespaces in C
> Underscore capital, double underscore, and underscore 't' suffixes should be
> avoided.
> +
> +3. Low level memory management
> +
> +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 qemu_malloc/qemu_mallocz/qemu_realloc/qemu_free or
> +qemu_vmalloc/qemu_memalign/qemu_vfree APIs.
> +
> +Memory allocated by qemu_vmalloc or qemu_memalign must be freed with
> +qemu_vfree, since breaking this will cause problems on Win32 and user
> +emulators.
Maybe add that a NULL check for the qemu_malloc result is redundant.
And a warning about the stupid qemu_malloc(0) behaviour would be
appropriate, too. Because if you don't know it, you'll write buggy code.
Kevin
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-08-27 8:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-26 18:38 [Qemu-devel] [PATCH 3/5] HACKING: add memory management rules Blue Swirl
2010-08-27 8:45 ` Kevin Wolf
-- strict thread matches above, loose matches on Subject: below --
2010-08-15 17:50 Blue Swirl
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).