qemu/tests/libqos/malloc-generic.c
<<
>>
Prefs
   1/*
   2 * Basic libqos generic malloc support
   3 *
   4 * Copyright (c) 2014 Marc MarĂ­
   5 *
   6 * This work is licensed under the terms of the GNU GPL, version 2 or later.
   7 * See the COPYING file in the top-level directory.
   8 */
   9
  10#include "qemu/osdep.h"
  11#include "libqos/malloc-generic.h"
  12#include "libqos/malloc.h"
  13
  14/*
  15 * Mostly for valgrind happiness, but it does offer
  16 * a chokepoint for debugging guest memory leaks, too.
  17 */
  18void generic_alloc_uninit(QGuestAllocator *allocator)
  19{
  20    alloc_uninit(allocator);
  21}
  22
  23QGuestAllocator *generic_alloc_init_flags(uint64_t base_addr, uint64_t size,
  24                                        uint32_t page_size, QAllocOpts flags)
  25{
  26    QGuestAllocator *s;
  27    uint64_t start = base_addr + (1 << 20); /* Start at 1MB */
  28
  29    s = alloc_init_flags(flags, start, start + size);
  30    alloc_set_page_size(s, page_size);
  31
  32    return s;
  33}
  34
  35inline QGuestAllocator *generic_alloc_init(uint64_t base_addr, uint64_t size,
  36                                                            uint32_t page_size)
  37{
  38    return generic_alloc_init_flags(base_addr, size, page_size, ALLOC_NO_FLAGS);
  39}
  40