[syslinux:pathbased] com32: wrapper functions for lowmem allocations

syslinux-bot for H. Peter Anvin hpa at zytor.com
Wed Feb 24 12:00:18 PST 2010


Commit-ID:  f3c1e08946a59b1aae2536436ea9384eafe3ad10
Gitweb:     http://syslinux.zytor.com/commit/f3c1e08946a59b1aae2536436ea9384eafe3ad10
Author:     H. Peter Anvin <hpa at zytor.com>
AuthorDate: Wed, 24 Feb 2010 11:56:43 -0800
Committer:  H. Peter Anvin <hpa at zytor.com>
CommitDate: Wed, 24 Feb 2010 11:56:43 -0800

com32: wrapper functions for lowmem allocations

lmalloc(), lfree(), lstrdup()

Signed-off-by: H. Peter Anvin <hpa at zytor.com>


---
 com32/include/com32.h             |    7 +++++++
 com32/lib/Makefile                |    2 ++
 com32/lib/{exit.c => lmalloc.c}   |   19 +++++++++----------
 com32/lib/{strdup.c => lstrdup.c} |    7 ++++---
 4 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/com32/include/com32.h b/com32/include/com32.h
index 9334efb..abbb9bf 100644
--- a/com32/include/com32.h
+++ b/com32/include/com32.h
@@ -117,6 +117,13 @@ int __cfarcall(uint16_t __cs, uint16_t __ip,
 extern const com32sys_t __com32_zero_regs;
 
 /*
+ * Lowmem allocation functions
+ */
+void *lmalloc(size_t);
+void lfree(void *);
+char *lstrdup(const char *);
+
+/*
  * These functions convert between linear pointers in the range
  * 0..0xFFFFF and real-mode style SEG:OFFS pointers.  Note that a
  * 32-bit linear pointer is not compatible with a SEG:OFFS pointer
diff --git a/com32/lib/Makefile b/com32/lib/Makefile
index 8750579..8aad4f8 100644
--- a/com32/lib/Makefile
+++ b/com32/lib/Makefile
@@ -27,6 +27,8 @@ LIBOBJS = \
 	asprintf.o vasprintf.o strlcpy.o strlcat.o			\
 	vsscanf.o zalloc.o						\
 	\
+	lmalloc.o lstrdup.o						\
+	\
 	dprintf.o vdprintf.o						\
 	\
 	opendir.o readdir.o closedir.o getcwd.o chdir.o fdopendir.o	\
diff --git a/com32/lib/exit.c b/com32/lib/lmalloc.c
similarity index 84%
copy from com32/lib/exit.c
copy to com32/lib/lmalloc.c
index ccd6f1e..a73817e 100644
--- a/com32/lib/exit.c
+++ b/com32/lib/lmalloc.c
@@ -1,6 +1,6 @@
 /* ----------------------------------------------------------------------- *
  *
- *   Copyright 2004-2008 H. Peter Anvin - All Rights Reserved
+ *   Copyright 2010 Intel Corporation; author: H. Peter Anvin
  *
  *   Permission is hereby granted, free of charge, to any person
  *   obtaining a copy of this software and associated documentation
@@ -25,17 +25,16 @@
  *
  * ----------------------------------------------------------------------- */
 
-/*
- * exit.c
- *
- * The regular exit
- */
-
+#include <com32.h>
 #include <stdlib.h>
+#include <syslinux/pmapi.h>
 
-extern __noreturn(*__exit_handler) (int);
+void *lmalloc(size_t size)
+{
+    return __com32.cs_pm->lmalloc(size);
+}
 
-__noreturn exit(int rv)
+void lfree(void *ptr)
 {
-    __exit_handler(rv);
+    __com32.cs_pm->lfree(ptr);
 }
diff --git a/com32/lib/strdup.c b/com32/lib/lstrdup.c
similarity index 58%
copy from com32/lib/strdup.c
copy to com32/lib/lstrdup.c
index 766958b..d11efe7 100644
--- a/com32/lib/strdup.c
+++ b/com32/lib/lstrdup.c
@@ -1,14 +1,15 @@
 /*
- * strdup.c
+ * lstrdup.c
  */
 
 #include <string.h>
 #include <stdlib.h>
+#include <com32.h>
 
-char *strdup(const char *s)
+char *lstrdup(const char *s)
 {
     int l = strlen(s) + 1;
-    char *d = malloc(l);
+    char *d = lmalloc(l);
 
     if (d)
 	memcpy(d, s, l);



More information about the Syslinux-commits mailing list