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 18 years ago
parent
commit
544fa25928

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

25
 
25
 
26
 #include <gpxe/uaccess.h>
26
 #include <gpxe/uaccess.h>
27
 #include <gpxe/hidemem.h>
27
 #include <gpxe/hidemem.h>
28
-#include <gpxe/emalloc.h>
28
+#include <gpxe/umalloc.h>
29
 
29
 
30
 /** Alignment of external allocated memory */
30
 /** Alignment of external allocated memory */
31
 #define EM_ALIGN ( 4 * 1024 )
31
 #define EM_ALIGN ( 4 * 1024 )
76
 /**
76
 /**
77
  * Reallocate external memory
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
  * @v new_size		Requested size
80
  * @v new_size		Requested size
81
  * @ret new_ptr		Allocated memory, or UNULL
81
  * @ret new_ptr		Allocated memory, or UNULL
82
  *
82
  *
83
  * Calling realloc() with a new size of zero is a valid way to free a
83
  * Calling realloc() with a new size of zero is a valid way to free a
84
  * memory block.
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
 	struct external_memory extmem;
87
 	struct external_memory extmem;
88
 	userptr_t new = ptr;
88
 	userptr_t new = ptr;
89
 	size_t align;
89
 	size_t align;
153
  *
153
  *
154
  * Memory is guaranteed to be aligned to a page boundary.
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
  * Free external memory
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
  * If @c ptr is UNULL, no action is taken.
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
 
25
 
26
 #include <errno.h>
26
 #include <errno.h>
27
 #include <gpxe/buffer.h>
27
 #include <gpxe/buffer.h>
28
-#include <gpxe/emalloc.h>
28
+#include <gpxe/umalloc.h>
29
 #include <gpxe/ebuffer.h>
29
 #include <gpxe/ebuffer.h>
30
 
30
 
31
 /**
31
 /**
46
 		actual_len <<= 1;
46
 		actual_len <<= 1;
47
 
47
 
48
 	/* Reallocate buffer */
48
 	/* Reallocate buffer */
49
-	new_addr = erealloc ( buffer->addr, actual_len );
49
+	new_addr = urealloc ( buffer->addr, actual_len );
50
 	if ( ! new_addr )
50
 	if ( ! new_addr )
51
 		return -ENOMEM;
51
 		return -ENOMEM;
52
 
52
 
63
  * @ret rc		Return status code
63
  * @ret rc		Return status code
64
  *
64
  *
65
  * Allocates space for the buffer and stores it in @c buffer->addr.
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
 int ebuffer_alloc ( struct buffer *buffer, size_t len ) {
68
 int ebuffer_alloc ( struct buffer *buffer, size_t len ) {
69
 	memset ( buffer, 0, sizeof ( *buffer ) );
69
 	memset ( buffer, 0, sizeof ( *buffer ) );

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

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

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

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

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
 #include <vsprintf.h>
1
 #include <vsprintf.h>
2
 #include <gpxe/uaccess.h>
2
 #include <gpxe/uaccess.h>
3
-#include <gpxe/emalloc.h>
3
+#include <gpxe/umalloc.h>
4
 #include <gpxe/memmap.h>
4
 #include <gpxe/memmap.h>
5
 
5
 
6
-void emalloc_test ( void ) {
6
+void umalloc_test ( void ) {
7
 	struct memory_map memmap;
7
 	struct memory_map memmap;
8
 	userptr_t bob;
8
 	userptr_t bob;
9
 	userptr_t fred;
9
 	userptr_t fred;
11
 	printf ( "Before allocation:\n" );
11
 	printf ( "Before allocation:\n" );
12
 	get_memmap ( &memmap );
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
 	printf ( "After allocation:\n" );
18
 	printf ( "After allocation:\n" );
19
 	get_memmap ( &memmap );
19
 	get_memmap ( &memmap );
20
 
20
 
21
-	efree ( bob );
22
-	efree ( fred );
21
+	ufree ( bob );
22
+	ufree ( fred );
23
 
23
 
24
 	printf ( "After freeing:\n" );
24
 	printf ( "After freeing:\n" );
25
 	get_memmap ( &memmap );
25
 	get_memmap ( &memmap );

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

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

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

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

Loading…
Cancel
Save