source: rtems-libbsd/rtemsbsd/src/rtems-bsd-malloc.c @ 41880b2

4.1155-freebsd-126-freebsd-12freebsd-9.3
Last change on this file since 41880b2 was 41880b2, checked in by Sebastian Huber <sebastian.huber@…>, on 04/18/12 at 15:40:39

Move M_IOV to reduce dependencies

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup rtems_bsd_rtems
5 *
6 * @brief TODO.
7 */
8
9/*
10 * Copyright (c) 2009, 2010 embedded brains GmbH.  All rights reserved.
11 *
12 *  embedded brains GmbH
13 *  Obere Lagerstr. 30
14 *  82178 Puchheim
15 *  Germany
16 *  <rtems@embedded-brains.de>
17 *
18 * The license and distribution terms for this file may be
19 * found in the file LICENSE in this distribution or at
20 * http://www.rtems.com/license/LICENSE.
21 */
22
23#include <freebsd/machine/rtems-bsd-config.h>
24
25#include <freebsd/sys/param.h>
26#include <freebsd/sys/types.h>
27#include <freebsd/sys/systm.h>
28#include <freebsd/sys/malloc.h>
29#include <freebsd/sys/kernel.h>
30
31MALLOC_DEFINE(M_DEVBUF, "devbuf", "device driver memory");
32
33MALLOC_DEFINE(M_TEMP, "temp", "misc temporary data buffers");
34
35MALLOC_DEFINE(M_IP6OPT, "ip6opt", "IPv6 options");
36MALLOC_DEFINE(M_IP6NDP, "ip6ndp", "IPv6 Neighbor Discovery");
37
38MALLOC_DEFINE(M_IOV, "iov", "large iov's");
39
40void
41malloc_init(void *data)
42{
43        struct malloc_type *mtp = data;
44}
45
46void
47malloc_uninit(void *data)
48{
49        struct malloc_type *mtp = data;
50
51        BSD_PRINTF( "desc = %s\n", mtp->ks_shortdesc);
52}
53
54#undef malloc
55
56void *
57_bsd_malloc(unsigned long size, struct malloc_type *mtp, int flags)
58{
59        void *p = malloc(size);
60
61        if ((flags & M_ZERO) != 0 && p != NULL) {
62                memset(p, 0, size);
63        }
64
65        return p;
66}
67
68#undef realloc
69void *
70_bsd_realloc( void *addr, unsigned long size,
71  struct malloc_type *type, int flags)
72{
73        void *p = realloc(addr, size);
74
75        if ((flags & M_ZERO) != 0 && p != NULL) {
76                memset(p, 0, size);
77        }
78
79        return p;
80}
81
82#undef free
83
84void
85_bsd_free(void *addr, struct malloc_type *mtp)
86{
87        free(addr);
88}
89
90#undef strdup
91
92char *
93_bsd_strdup(const char *__restrict s, struct malloc_type *type)
94{
95        return strdup(s);
96}
Note: See TracBrowser for help on using the repository browser.