Browse Source

Rename e{malloc,realloc,free} to u{malloc,realloc,free}, to more obviously

reflect the fact that they allocate and deallocate user memory (i.e.
things reached through a userptr_t).
tags/v0.9.3
Michael Brown 17 years ago
parent
commit
544fa25928

src/arch/i386/core/emalloc.c → src/arch/i386/core/umalloc.c View File

@@ -25,7 +25,7 @@
25 25
 
26 26
 #include <gpxe/uaccess.h>
27 27
 #include <gpxe/hidemem.h>
28
-#include <gpxe/emalloc.h>
28
+#include <gpxe/umalloc.h>
29 29
 
30 30
 /** Alignment of external allocated memory */
31 31
 #define EM_ALIGN ( 4 * 1024 )
@@ -76,14 +76,14 @@ static void ecollect_free ( void ) {
76 76
 /**
77 77
  * Reallocate external memory
78 78
  *
79
- * @v old_ptr		Memory previously allocated by emalloc(), or UNULL
79
+ * @v old_ptr		Memory previously allocated by umalloc(), or UNULL
80 80
  * @v new_size		Requested size
81 81
  * @ret new_ptr		Allocated memory, or UNULL
82 82
  *
83 83
  * Calling realloc() with a new size of zero is a valid way to free a
84 84
  * memory block.
85 85
  */
86
-userptr_t erealloc ( userptr_t ptr, size_t new_size ) {
86
+userptr_t urealloc ( userptr_t ptr, size_t new_size ) {
87 87
 	struct external_memory extmem;
88 88
 	userptr_t new = ptr;
89 89
 	size_t align;
@@ -153,17 +153,17 @@ userptr_t erealloc ( userptr_t ptr, size_t new_size ) {
153 153
  *
154 154
  * Memory is guaranteed to be aligned to a page boundary.
155 155
  */
156
-userptr_t emalloc ( size_t size ) {
157
-	return erealloc ( UNULL, size );
156
+userptr_t umalloc ( size_t size ) {
157
+	return urealloc ( UNULL, size );
158 158
 }
159 159
 
160 160
 /**
161 161
  * Free external memory
162 162
  *
163
- * @v ptr		Memory allocated by emalloc(), or UNULL
163
+ * @v ptr		Memory allocated by umalloc(), or UNULL
164 164
  *
165 165
  * If @c ptr is UNULL, no action is taken.
166 166
  */
167
-void efree ( userptr_t ptr ) {
168
-	erealloc ( ptr, 0 );
167
+void ufree ( userptr_t ptr ) {
168
+	urealloc ( ptr, 0 );
169 169
 }

+ 3
- 3
src/core/ebuffer.c View File

@@ -25,7 +25,7 @@
25 25
 
26 26
 #include <errno.h>
27 27
 #include <gpxe/buffer.h>
28
-#include <gpxe/emalloc.h>
28
+#include <gpxe/umalloc.h>
29 29
 #include <gpxe/ebuffer.h>
30 30
 
31 31
 /**
@@ -46,7 +46,7 @@ static int ebuffer_expand ( struct buffer *buffer, size_t new_len ) {
46 46
 		actual_len <<= 1;
47 47
 
48 48
 	/* Reallocate buffer */
49
-	new_addr = erealloc ( buffer->addr, actual_len );
49
+	new_addr = urealloc ( buffer->addr, actual_len );
50 50
 	if ( ! new_addr )
51 51
 		return -ENOMEM;
52 52
 
@@ -63,7 +63,7 @@ static int ebuffer_expand ( struct buffer *buffer, size_t new_len ) {
63 63
  * @ret rc		Return status code
64 64
  *
65 65
  * Allocates space for the buffer and stores it in @c buffer->addr.
66
- * The space must eventually be freed by calling efree(buffer->addr).
66
+ * The space must eventually be freed by calling ufree(buffer->addr).
67 67
  */
68 68
 int ebuffer_alloc ( struct buffer *buffer, size_t len ) {
69 69
 	memset ( buffer, 0, sizeof ( *buffer ) );

+ 0
- 1
src/core/image.c View File

@@ -23,7 +23,6 @@
23 23
 #include <assert.h>
24 24
 #include <vsprintf.h>
25 25
 #include <gpxe/list.h>
26
-#include <gpxe/emalloc.h>
27 26
 #include <gpxe/image.h>
28 27
 
29 28
 /** @file

+ 0
- 17
src/include/gpxe/emalloc.h View File

@@ -1,17 +0,0 @@
1
-#ifndef _GPXE_EMALLOC_H
2
-#define _GPXE_EMALLOC_H
3
-
4
-/**
5
- * @file
6
- *
7
- * External memory allocation
8
- *
9
- */
10
-
11
-#include <gpxe/uaccess.h>
12
-
13
-extern userptr_t emalloc ( size_t size );
14
-extern userptr_t erealloc ( userptr_t ptr, size_t new_size );
15
-extern void efree ( userptr_t ptr );
16
-
17
-#endif /* _GPXE_EMALLOC_H */

+ 17
- 0
src/include/gpxe/umalloc.h View File

@@ -0,0 +1,17 @@
1
+#ifndef _GPXE_UMALLOC_H
2
+#define _GPXE_UMALLOC_H
3
+
4
+/**
5
+ * @file
6
+ *
7
+ * User memory allocation
8
+ *
9
+ */
10
+
11
+#include <gpxe/uaccess.h>
12
+
13
+extern userptr_t umalloc ( size_t size );
14
+extern userptr_t urealloc ( userptr_t ptr, size_t new_size );
15
+extern void ufree ( userptr_t ptr );
16
+
17
+#endif /* _GPXE_UMALLOC_H */

src/tests/emalloc_test.c → src/tests/umalloc_test.c View File

@@ -1,9 +1,9 @@
1 1
 #include <vsprintf.h>
2 2
 #include <gpxe/uaccess.h>
3
-#include <gpxe/emalloc.h>
3
+#include <gpxe/umalloc.h>
4 4
 #include <gpxe/memmap.h>
5 5
 
6
-void emalloc_test ( void ) {
6
+void umalloc_test ( void ) {
7 7
 	struct memory_map memmap;
8 8
 	userptr_t bob;
9 9
 	userptr_t fred;
@@ -11,15 +11,15 @@ void emalloc_test ( void ) {
11 11
 	printf ( "Before allocation:\n" );
12 12
 	get_memmap ( &memmap );
13 13
 
14
-	bob = emalloc ( 1234 );
15
-	bob = erealloc ( bob, 12345 );
16
-	fred = emalloc ( 999 );
14
+	bob = ymalloc ( 1234 );
15
+	bob = yrealloc ( bob, 12345 );
16
+	fred = ymalloc ( 999 );
17 17
 
18 18
 	printf ( "After allocation:\n" );
19 19
 	get_memmap ( &memmap );
20 20
 
21
-	efree ( bob );
22
-	efree ( fred );
21
+	ufree ( bob );
22
+	ufree ( fred );
23 23
 
24 24
 	printf ( "After freeing:\n" );
25 25
 	get_memmap ( &memmap );

+ 4
- 4
src/usr/fetch.c View File

@@ -25,7 +25,7 @@
25 25
 
26 26
 #include <errno.h>
27 27
 #include <vsprintf.h>
28
-#include <gpxe/emalloc.h>
28
+#include <gpxe/umalloc.h>
29 29
 #include <gpxe/ebuffer.h>
30 30
 #include <gpxe/image.h>
31 31
 #include <gpxe/uri.h>
@@ -45,9 +45,9 @@
45 45
  * @ret len		Length of loaded file
46 46
  * @ret rc		Return status code
47 47
  *
48
- * Fetch file to an external buffer allocated with emalloc().  The
48
+ * Fetch file to an external buffer allocated with umalloc().  The
49 49
  * caller is responsible for eventually freeing the buffer with
50
- * efree().
50
+ * ufree().
51 51
  */
52 52
 int fetch ( const char *uri_string, userptr_t *data, size_t *len ) {
53 53
 	struct uri *uri;
@@ -101,7 +101,7 @@ int fetch ( const char *uri_string, userptr_t *data, size_t *len ) {
101 101
 	return 0;
102 102
 
103 103
  err:
104
-	efree ( buffer.addr );
104
+	ufree ( buffer.addr );
105 105
  err_ebuffer_alloc:
106 106
 	free_uri ( uri );
107 107
  err_parse_uri:

+ 3
- 3
src/usr/imgmgmt.c View File

@@ -21,7 +21,7 @@
21 21
 #include <errno.h>
22 22
 #include <vsprintf.h>
23 23
 #include <gpxe/image.h>
24
-#include <gpxe/emalloc.h>
24
+#include <gpxe/umalloc.h>
25 25
 #include <usr/fetch.h>
26 26
 #include <usr/imgmgmt.h>
27 27
 
@@ -66,7 +66,7 @@ int imgfetch ( const char *filename, const char *name,
66 66
 	return 0;
67 67
 
68 68
  err:
69
-	efree ( image->data );
69
+	ufree ( image->data );
70 70
 	free ( image );
71 71
 	return rc;
72 72
 }
@@ -139,6 +139,6 @@ void imgstat ( struct image *image ) {
139 139
  */
140 140
 void imgfree ( struct image *image ) {
141 141
 	unregister_image ( image );
142
-	efree ( image->data );
142
+	ufree ( image->data );
143 143
 	free ( image );
144 144
 }

Loading…
Cancel
Save