Browse Source

Move ANSI C standard prototypes to stdlib.h; leave the gPXE-specific

function prototypes (e.g. malloc_dma()) in malloc.h.
tags/v0.9.3
Michael Brown 18 years ago
parent
commit
3e0286dee3
2 changed files with 28 additions and 20 deletions
  1. 8
    20
      src/include/malloc.h
  2. 20
    0
      src/include/stdlib.h

+ 8
- 20
src/include/malloc.h View File

@@ -9,11 +9,16 @@
9 9
  *
10 10
  */
11 11
 
12
+/*
13
+ * Prototypes for the standard functions (malloc() et al) are in
14
+ * stdlib.h.  Include <malloc.h> only if you need the non-standard
15
+ * functions, such as malloc_dma().
16
+ *
17
+ */
18
+#include <stdlib.h>
19
+
12 20
 extern void * alloc_memblock ( size_t size, size_t align );
13 21
 extern void free_memblock ( void *ptr, size_t size );
14
-extern void * realloc ( void *old_ptr, size_t new_size );
15
-extern void * malloc ( size_t size );
16
-extern void free ( void *ptr );
17 22
 extern void mpopulate ( void *start, size_t len );
18 23
 extern void mdumpfree ( void );
19 24
 
@@ -47,21 +52,4 @@ static inline void free_dma ( void *ptr, size_t size ) {
47 52
 	free_memblock ( ptr, size );
48 53
 }
49 54
 
50
-/**
51
- * Allocate cleared memory
52
- *
53
- * @v nmemb		Number of members
54
- * @v size		Size of each member
55
- * @ret ptr		Allocated memory
56
- *
57
- * Allocate memory as per malloc(), and zero it.
58
- *
59
- * Note that malloc() and calloc() are identical, in the interests of
60
- * reducing code size.  Callers should not, however, rely on malloc()
61
- * clearing memory, since this behaviour may change in future.
62
- */
63
-static inline void * calloc ( size_t nmemb, size_t size ) {
64
-	return malloc ( nmemb * size );
65
-}
66
-
67 55
 #endif /* _MALLOC_H */

+ 20
- 0
src/include/stdlib.h View File

@@ -2,5 +2,25 @@
2 2
 #define STDLIB_H
3 3
 
4 4
 extern unsigned long strtoul ( const char *p, char **endp, int base );
5
+extern void * realloc ( void *old_ptr, size_t new_size );
6
+extern void * malloc ( size_t size );
7
+extern void free ( void *ptr );
8
+
9
+/**
10
+ * Allocate cleared memory
11
+ *
12
+ * @v nmemb		Number of members
13
+ * @v size		Size of each member
14
+ * @ret ptr		Allocated memory
15
+ *
16
+ * Allocate memory as per malloc(), and zero it.
17
+ *
18
+ * Note that malloc() and calloc() are identical, in the interests of
19
+ * reducing code size.  Callers should not, however, rely on malloc()
20
+ * clearing memory, since this behaviour may change in future.
21
+ */
22
+static inline void * calloc ( size_t nmemb, size_t size ) {
23
+	return malloc ( nmemb * size );
24
+}
5 25
 
6 26
 #endif /* STDLIB_H */

Loading…
Cancel
Save