From: Martin Mares Date: Thu, 9 Feb 2012 22:33:00 +0000 (+0100) Subject: Moved memory allocation functions together and document them X-Git-Tag: v5.0~82 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=cfc8e04fa8ed6daa7a617187303c57a10380795e;p=libucw.git Moved memory allocation functions together and document them --- diff --git a/ucw/lib.h b/ucw/lib.h index 7af29468..ebb6d32a 100644 --- a/ucw/lib.h +++ b/ucw/lib.h @@ -166,6 +166,17 @@ void xfree(void *); /** Free memory allocated by xmalloc() or xrealloc(). **/ void *xmalloc_zero(size_t) LIKE_MALLOC; /** Allocate memory and fill it by zeroes. **/ char *xstrdup(const char *) LIKE_MALLOC; /** Make a xmalloc()'ed copy of a string. Returns NULL for NULL string. **/ +/* bigalloc.c */ + +void *page_alloc(u64 len) LIKE_MALLOC; // Internal: allocates a multiple of CPU_PAGE_SIZE bytes with mmap +void *page_alloc_zero(u64 len) LIKE_MALLOC; +void page_free(void *start, u64 len); +void *page_realloc(void *start, u64 old_len, u64 new_len); + +void *big_alloc(u64 len) LIKE_MALLOC; /** Allocate a large memory block in the most efficient way available. **/ +void *big_alloc_zero(u64 len) LIKE_MALLOC; /** Allocate and clear a large memory block. **/ +void big_free(void *start, u64 len); /** Free block allocated by @big_alloc() or @big_alloc_zero(). **/ + /*** === Trivial timers (timer.c) ***/ timestamp_t get_timestamp(void); /** Get current time as a millisecond timestamp. **/ @@ -181,15 +192,4 @@ uns random_max(uns max); /** Return a pseudorandom 32-bit number in range [0,@ u64 random_u64(void); /** Return a pseudorandom 64-bit number. **/ u64 random_max_u64(u64 max); /** Return a pseudorandom 64-bit number in range [0,@max). **/ -/* bigalloc.c */ - -void *page_alloc(u64 len) LIKE_MALLOC; // allocates a multiple of CPU_PAGE_SIZE bytes with mmap -void *page_alloc_zero(u64 len) LIKE_MALLOC; -void page_free(void *start, u64 len); -void *page_realloc(void *start, u64 old_len, u64 new_len); - -void *big_alloc(u64 len) LIKE_MALLOC; // allocate a large memory block in the most efficient way available -void *big_alloc_zero(u64 len) LIKE_MALLOC; -void big_free(void *start, u64 len); - #endif