summaryrefslogtreecommitdiff
path: root/libc/stdlib/malloc-simple
diff options
context:
space:
mode:
Diffstat (limited to 'libc/stdlib/malloc-simple')
-rw-r--r--libc/stdlib/malloc-simple/.indent.pro33
-rw-r--r--libc/stdlib/malloc-simple/Makefile49
-rw-r--r--libc/stdlib/malloc-simple/alloc.c141
3 files changed, 0 insertions, 223 deletions
diff --git a/libc/stdlib/malloc-simple/.indent.pro b/libc/stdlib/malloc-simple/.indent.pro
deleted file mode 100644
index 492ecf1c7..000000000
--- a/libc/stdlib/malloc-simple/.indent.pro
+++ /dev/null
@@ -1,33 +0,0 @@
---blank-lines-after-declarations
---blank-lines-after-procedures
---break-before-boolean-operator
---no-blank-lines-after-commas
---braces-on-if-line
---braces-on-struct-decl-line
---comment-indentation25
---declaration-comment-column25
---no-comment-delimiters-on-blank-lines
---cuddle-else
---continuation-indentation4
---case-indentation0
---else-endif-column33
---space-after-cast
---line-comments-indentation0
---declaration-indentation1
---dont-format-first-column-comments
---dont-format-comments
---honour-newlines
---indent-level4
-/* changed from 0 to 4 */
---parameter-indentation4
---line-length78 /* changed from 75 */
---continue-at-parentheses
---no-space-after-function-call-names
---dont-break-procedure-type
---dont-star-comments
---leave-optional-blank-lines
---dont-space-special-semicolon
---tab-size4
-/* additions by Mark */
---case-brace-indentation0
---leave-preprocessor-space
diff --git a/libc/stdlib/malloc-simple/Makefile b/libc/stdlib/malloc-simple/Makefile
deleted file mode 100644
index f8fe3520d..000000000
--- a/libc/stdlib/malloc-simple/Makefile
+++ /dev/null
@@ -1,49 +0,0 @@
-# Makefile for uClibc
-#
-# Copyright (C) 2000 by Lineo, inc.
-# Copyright (C) 2000,2001 Erik Andersen <andersen@uclibc.org>
-#
-# This program is free software; you can redistribute it and/or modify it under
-# the terms of the GNU Library General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option) any
-# later version.
-#
-# This program 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 Library General Public License for more
-# details.
-#
-# You should have received a copy of the GNU Library General Public License
-# along with this program; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# Derived in part from the Linux-8086 C library, the GNU C Library, and several
-# other sundry sources. Files within this library are copyright by their
-# respective copyright holders.
-
-TOPDIR=../../../
-include $(TOPDIR)Rules.mak
-
-MSRC=alloc.c
-MOBJ=malloc.o realloc.o free.o calloc.o #malloc_dbg.o free_dbg.o calloc_dbg.o
-OBJS=$(MOBJ)
-
-
-all: $(OBJS) $(LIBC)
-
-$(LIBC): ar-target
-
-ar-target: $(OBJS)
- $(AR) $(ARFLAGS) $(LIBC) $(OBJS)
-
-$(MOBJ): $(MSRC)
- $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
- $(STRIPTOOL) -x -R .note -R .comment $*.o
-
-$(COBJS): %.o : %.c
- $(CC) $(CFLAGS) -c $< -o $@
- $(STRIPTOOL) -x -R .note -R .comment $*.o
-
-clean:
- rm -f *.[oa] *~ core
-
diff --git a/libc/stdlib/malloc-simple/alloc.c b/libc/stdlib/malloc-simple/alloc.c
deleted file mode 100644
index 1824507eb..000000000
--- a/libc/stdlib/malloc-simple/alloc.c
+++ /dev/null
@@ -1,141 +0,0 @@
-
-/*
- * For MMU hosts we need to track the size of the allocations otherwise
- * munmap will fail to free the memory (EINVAL).
- */
-
-#include <features.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/mman.h>
-
-
-#ifdef L_calloc_dbg
-
-void *calloc_dbg(size_t num, size_t size, char *function, char *file,
- int line)
-{
- void *ptr;
-
- fprintf(stderr, "calloc of %d bytes at %s @%s:%d = ", (int) (num * size),
- function, file, line);
- ptr = calloc(num, size);
- fprintf(stderr, "%p\n", ptr);
- return ptr;
-}
-
-#endif
-
-#ifdef L_malloc_dbg
-
-void *malloc_dbg(size_t size, char *function, char *file, int line)
-{
- void *result;
-
- fprintf(stderr, "malloc of %d bytes at %s @%s:%d = ", (int) size, function,
- file, line);
- result = malloc(size);
- fprintf(stderr, "%p\n", result);
- return result;
-}
-
-#endif
-
-#ifdef L_free_dbg
-
-void free_dbg(void *ptr, char *function, char *file, int line)
-{
- fprintf(stderr, "free of %p at %s @%s:%d\n", ptr, function, file,
- line);
- free(ptr);
-}
-
-#endif
-
-
-#ifdef L_calloc
-
-void *calloc(size_t num, size_t size)
-{
- void *ptr = malloc(num * size);
-
- if (ptr)
- memset(ptr, 0, num * size);
- return ptr;
-}
-
-#endif
-
-#ifdef L_malloc
-
-void *malloc(size_t size)
-{
- void *result;
-
- /* Some programs will call malloc (0). Lets be strict and return NULL */
- if (size == 0)
- return NULL;
-
-#ifdef __UCLIBC_HAS_MMU__
- result = mmap((void *) 0, size + sizeof(size_t), PROT_READ | PROT_WRITE,
- MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
-#else
- result = mmap((void *) 0, size, PROT_READ | PROT_WRITE,
- MAP_SHARED | MAP_ANONYMOUS, 0, 0);
-#endif
-
- if (result == MAP_FAILED)
- return 0;
-
-#ifdef __UCLIBC_HAS_MMU__
- * (size_t *) result = size;
- return(result + sizeof(size_t));
-#else
- return(result);
-#endif
-}
-
-#endif
-
-#ifdef L_free
-
-void free(void *ptr)
-{
-#ifdef __UCLIBC_HAS_MMU__
- if (ptr) {
- ptr -= sizeof(size_t);
- munmap(ptr, * (size_t *) ptr + sizeof(size_t));
- }
-#else
- munmap(ptr, 0);
-#endif
-}
-
-#endif
-
-#ifdef L_realloc
-
-void *realloc(void *ptr, size_t size)
-{
- void *newptr = NULL;
-
- if (size > 0) {
- newptr = malloc(size);
- if (newptr && ptr) {
-#ifdef __UCLIBC_HAS_MMU__
- memcpy(newptr, ptr, * ((size_t *) (ptr - sizeof(size_t))));
-#else
- memcpy(newptr, ptr, size);
-#endif
- free(ptr);
- }
- }
- else
- free(ptr);
- return newptr;
-}
-
-#endif