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 <glib.h>
  12#include "libqos/malloc-generic.h"
  13#include "libqos/malloc.h"
  14
  15/*
  16 * Mostly for valgrind happiness, but it does offer
  17 * a chokepoint for debugging guest memory leaks, too.
  18 */
  19void generic_alloc_uninit(QGuestAllocator *allocator)
  20{
  21    alloc_uninit(allocator);
  22}
  23
  24QGuestAllocator *generic_alloc_init_flags(uint64_t base_addr, uint64_t size,
  25                                        uint32_t page_size, QAllocOpts flags)
  26{
  27    QGuestAllocator *s;
  28    uint64_t start = base_addr + (1 << 20); /* Start at 1MB */
  29
  30    s = alloc_init_flags(flags, start, start + size);
  31    alloc_set_page_size(s, page_size);
  32
  33    return s;
  34}
  35
  36inline QGuestAllocator *generic_alloc_init(uint64_t base_addr, uint64_t size,
  37                                                            uint32_t page_size)
  38{
  39    return generic_alloc_init_flags(base_addr, size, page_size, ALLOC_NO_FLAGS);
  40}
  41