Pārlūkot izejas kodu

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

tags/v0.9.3
Michael Brown 17 gadus atpakaļ
vecāks
revīzija
058b200529
2 mainītis faili ar 7 papildinājumiem un 4 dzēšanām
  1. 4
    1
      src/core/malloc.c
  2. 3
    3
      src/include/stdlib.h

+ 4
- 1
src/core/malloc.c Parādīt failu

@@ -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 Parādīt failu

@@ -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
 /*****************************************************************************

Notiek ielāde…
Atcelt
Saglabāt