aboutsummaryrefslogtreecommitdiff
path: root/qemu-malloc.c
AgeCommit message (Collapse)AuthorFilesLines
2010-12-14Add missing tracing to qemu_mallocz()Jes Sorensen1-1/+4
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-10-30Consolidate oom_check() functionsJes Sorensen1-11/+3
This consolidates the duplicated oom_check() functions, as well as splitting them into OS dependant versions to avoid the #ifdef grossness that was present in the old osdep.c version. Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-09-09trace: Trace qemu_malloc() and qemu_vmalloc()Stefan Hajnoczi1-2/+10
It is often useful to instrument memory management functions in order to find leaks or performance problems. This patch adds trace events for the memory allocation primitives. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2010-06-15cow: stop using mmapChristoph Hellwig1-5/+0
We don't have an equivalent to mmap in the qemu block API, so read and write the bitmap directly. At least in the dumb implementation added in this patch this is a lot less efficient, but it means cow can also work on windows, and over nbd or curl. And it fixes qemu-iotests testcase 012 which did not work properly due to issues with read-only mmap access. In addition we can also get rid of the now unused get_mmap_addr function. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-05-28Use calloc in qemu_mallocz.Richard Henderson1-4/+4
Avoids the memset if the allocator has gotten new zeroed storage from the operating system. Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-02-23Simplify qemu_realloc()Markus Armbruster1-5/+3
No functional change. Bonus: looks just like qemu_malloc() now. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-12-12Do not abort on qemu_malloc(0) in production buildsAnthony Liguori1-6/+13
qemu_malloc() does not allow size=0 to be passed in and aborts on this behavior. Unfortunately, there is good reason to believe that within qemu, there are a number of, so far, undetected places that assume size=0 can be safely passed. Since we do not want to abort unnecessarily in production builds, return qemu_malloc(1) whenever the version file indicates that this is a production build. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-05-19Format per CODING_STYLEmalc1-6/+10
Signed-off-by: malc <av1474@comtv.ru>
2009-05-19Abort on attempts to allocate zero bytesmalc1-2/+7
http://marc.info/?t=124267873300015&r=1&w=2 Signed-off-by: malc <av1474@comtv.ru>
2009-02-11Fix qemu_realloc() (Kevin Wolf)aliguori1-1/+4
For qemu_realloc with size == 0 a result of NULL is perfectly fine Signed-off-by: Kevin Wolf <kwolf@suse.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6615 c046a42c-6fe2-441c-8c8c-71466251a162
2009-02-06Replace exit() in oom_check with abort()aliguori1-1/+1
So that we can get a core dump with a stack trace. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6542 c046a42c-6fe2-441c-8c8c-71466251a162
2009-02-05Terminate emulation on memory allocation failure (Avi Kivity)aliguori1-6/+10
Memory allocation failures are a very rare condition on virtual-memory hosts. They are also very difficult to handle correctly (especially in a hardware emulation context). Because of this, it is better to gracefully terminate emulation rather than executing untested or even unwritten recovery code paths. This patch changes the qemu memory allocation routines to terminate emulation if an allocation failure is encountered. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6526 c046a42c-6fe2-441c-8c8c-71466251a162
2008-11-09Add qemu_strndup: qemu_strdup with length limit.balrog1-1/+15
Also optimise qemu_strdup by using memcpy - using pstrcpy is usually suboptimal. git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5653 c046a42c-6fe2-441c-8c8c-71466251a162
2008-08-25Fix error introduced by r5044blueswir11-1/+1
qemu_strdup() doesn't copy a last character because of off by one error. Signed-off-by: Gleb Natapov <gleb@qumranet.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5086 c046a42c-6fe2-441c-8c8c-71466251a162
2008-08-21Fix OpenBSD linker warningsblueswir11-2/+3
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5044 c046a42c-6fe2-441c-8c8c-71466251a162
2008-08-06Add qemu_realloc(), by Gerd Hoffmann.ths1-0/+5
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4986 c046a42c-6fe2-441c-8c8c-71466251a162
2008-06-09Prevent guest reusing host memory allocations.pbrook1-0/+59
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4710 c046a42c-6fe2-441c-8c8c-71466251a162