kfusd/kfusd.c
static int maybe_expand_buffer(char **buf, int *buf_size, int len,
                               int space_needed)
{
	if (*buf_size - len < space_needed) {
		char *old_buf = *buf;

		*buf_size *= 2;
		*buf = KMALLOC(*buf_size, GFP_KERNEL);

		if (*buf != NULL)
			memmove(*buf, old_buf, len);
		KFREE(old_buf);
		if (*buf == NULL) {
			RDEBUG(1, "out of memory!");
			return -1;
		}
	}
	return 0;
}
/*
 * maybe_expand_buffer: expand a buffer exponentially as it fills.  We
 * are given:
 *
 * - A reference to a pointer to a buffer (buf)
 * - A reference to the buffer's current capacity (buf_size)
 * - The current amount of buffer space used (len)
 * - The amount of space we want to ensure is free in the buffer (space_needed)
 *
 * If there isn't at least space_needed difference between buf_size
 * and len, the existing contents are moved into a larger buffer. 
 */
expand a buffer exponentially as it fills.  We
are given.

- A reference to a pointer to a buffer (buf)
- A reference to the buffer's current capacity (buf_size)
- The current amount of buffer space used (len)
- The amount of space we want to ensure is free in the buffer (space_needed)

If there isn't at least space_needed difference between buf_size
and len, the existing contents are moved into a larger buffer.
expand a buffer exponentially as it fills . We are given . - A reference to a pointer to a buffer ( buf ) - A reference to the buffer ' s current capacity ( buf_size ) - The current amount of buffer space used ( len ) - The amount of space we want to ensure is free in the buffer ( space_needed ) If there isn ' t at least space_needed difference between buf_size and len the existing contents are moved into a larger buffer .
static int maybe_expand_buffer(char **buf, int *buf_size, int len,
                               int space_needed)
{
	if (*buf_size - len < space_needed) {
		char *old_buf = *buf;
		*buf_size *= 2;
		*buf = KMALLOC(*buf_size, GFP_KERNEL);
		if (*buf != NULL)
			memmove(*buf, old_buf, len);
		KFREE(old_buf);
		if (*buf == NULL) {
			RDEBUG(1, "out of memory!");
			return -1;
		}
	}
	return 0;
}
static int maybe_expand_buffer ( char * * buf , int * buf_size , int len , int space_needed ) { if ( * buf_size - len < space_needed ) { char * old_buf = * buf ; * buf_size *= 2 ; * buf = KMALLOC ( * buf_size , GFP_KERNEL ) ; if ( * buf != NULL ) memmove ( * buf , old_buf , len ) ; KFREE ( old_buf ) ; if ( * buf == NULL ) { RDEBUG ( 1 , " " ) ; return -1 ; } } return 0 ; }
maybe_expand_buffer: expand a buffer exponentially as it fills.
maybe_expand_buffer : expand a buffer exponentially as it fills .