Przeglądaj źródła

Renamed _calloc() to zalloc(), ready to be used as a standalone function.

tags/v0.9.3
Michael Brown 17 lat temu
rodzic
commit
058b200529
2 zmienionych plików z 7 dodań i 4 usunięć
  1. 4
    1
      src/core/malloc.c
  2. 3
    3
      src/include/stdlib.h

+ 4
- 1
src/core/malloc.c Wyświetl plik

@@ -311,8 +311,11 @@ void free ( void *ptr ) {
311 311
  * @ret ptr		Allocated memory
312 312
  *
313 313
  * Allocate memory as per malloc(), and zero it.
314
+ *
315
+ * This function name is non-standard, but pretty intuitive.
316
+ * zalloc(size) is always equivalent to calloc(1,size)
314 317
  */
315
-void * _calloc ( size_t size ) {
318
+void * zalloc ( size_t size ) {
316 319
 	void *data;
317 320
 
318 321
 	data = malloc ( size );

+ 3
- 3
src/include/stdlib.h Wyświetl plik

@@ -23,7 +23,7 @@ extern unsigned long strtoul ( const char *p, char **endp, int base );
23 23
 extern void * malloc ( size_t size );
24 24
 extern void * realloc ( void *old_ptr, size_t new_size );
25 25
 extern void free ( void *ptr );
26
-extern void * _calloc ( size_t len );
26
+extern void * zalloc ( size_t len );
27 27
 
28 28
 /**
29 29
  * Allocate cleared memory
@@ -35,11 +35,11 @@ extern void * _calloc ( size_t len );
35 35
  * Allocate memory as per malloc(), and zero it.
36 36
  *
37 37
  * This is implemented as a static inline, with the body of the
38
- * function in _calloc(), since in most cases @c nmemb will be 1 and
38
+ * function in zalloc(), since in most cases @c nmemb will be 1 and
39 39
  * doing the multiply is just wasteful.
40 40
  */
41 41
 static inline void * calloc ( size_t nmemb, size_t size ) {
42
-	return _calloc ( nmemb * size );
42
+	return zalloc ( nmemb * size );
43 43
 }
44 44
 
45 45
 /*****************************************************************************

Ładowanie…
Anuluj
Zapisz