diff options
-rw-r--r-- | libddekit/Makefile | 2 | ||||
-rw-r--r-- | libddekit/include/ddekit/memory.h | 13 | ||||
-rw-r--r-- | libddekit/malloc.c | 49 | ||||
-rw-r--r-- | libddekit/memory.c | 3 |
4 files changed, 15 insertions, 52 deletions
diff --git a/libddekit/Makefile b/libddekit/Makefile index 018d67c9..f2e52f25 100644 --- a/libddekit/Makefile +++ b/libddekit/Makefile @@ -19,7 +19,7 @@ dir := libddekit makemode := library libname = libddekit -SRCS= condvar.c init.c interrupt.c lock.c malloc.c memory.c \ +SRCS= condvar.c init.c interrupt.c lock.c memory.c \ pci.c pgtab.c printf.c resources.c list.c \ thread.c timer.c kmem.c LCLHDRS = include/ddekit/condvar.h include/ddekit/lock.h \ diff --git a/libddekit/include/ddekit/memory.h b/libddekit/include/ddekit/memory.h index 051a4d9e..2c573d8f 100644 --- a/libddekit/include/ddekit/memory.h +++ b/libddekit/include/ddekit/memory.h @@ -123,6 +123,9 @@ void *ddekit_contig_malloc( ** Simple memory allocator ** *****************************/ +#include <stdlib.h> +#include "ddekit/inline.h" + /** * Allocate memory block via simple allocator * @@ -132,13 +135,19 @@ void *ddekit_contig_malloc( * The blocks allocated via this allocator CANNOT be used for DMA or other * device operations, i.e., there exists no virt->phys mapping. */ -void *ddekit_simple_malloc(unsigned size); +static INLINE void *ddekit_simple_malloc(unsigned size) +{ + return malloc (size); +} /** * Free memory block via simple allocator * * \param p pointer to memory block */ -void ddekit_simple_free(void *p); +static INLINE void ddekit_simple_free(void *p) +{ + free (p); +} #endif diff --git a/libddekit/malloc.c b/libddekit/malloc.c deleted file mode 100644 index a30cd7b7..00000000 --- a/libddekit/malloc.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - Copyright (C) 2009 Free Software Foundation, Inc. - Written by Zheng Da. - - This file is part of the GNU Hurd. - - The GNU Hurd is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - The GNU Hurd is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with the GNU Hurd; see the file COPYING. If not, write to - the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/** - * Allocate memory block via simple allocator - * - * \param size block size - * \return pointer to new memory block - * - * The blocks allocated via this allocator CANNOT be used for DMA or other - * device operations, i.e., there exists no virt->phys mapping. - * - * Each chunk stores its size in the first word for free() to work. - */ - -#include <stdlib.h> - -void *ddekit_simple_malloc(unsigned size) -{ - return malloc (size); -} - - -/** - * Free memory block via simple allocator - * - * \param p pointer to memory block - */ -void ddekit_simple_free(void *p) -{ - free (p); -} diff --git a/libddekit/memory.c b/libddekit/memory.c index 1ffb15b0..781a4bae 100644 --- a/libddekit/memory.c +++ b/libddekit/memory.c @@ -160,6 +160,9 @@ struct ddekit_slab * ddekit_slab_init(unsigned size, int contiguous) * Free large block of memory * * This is no useful for allocation < page size. + * + * TODO The freed memory can be cached and will be still accessible ( + * no page fault when accessed). I hope it won't caused any troubles. */ void ddekit_large_free(void *objp) { |