⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 big_buffer.c

📁 seed格式数据解压程序,地震分析人员必备
💻 C
字号:
/*===========================================================================*//* DMC interim out |        big_buffer.c                   | Utility         *//*===========================================================================*//*	Name:		big_buffer.c	Purpose:	make large contiguous dynamic buffers	Usage:		err = big_buffer( bottom, top, size )	Input:		char *bottom	bottom of existing buffer or NULL				char *top		top of used part of buffer or NULL								(points to lastused+1)				int	size		chunk size for allocation	Output:		err				fatal if allocation error	Externals:		Warnings:		Errors:			Fatals:		allocation error	Called by:		Calls to:		Algorithm:	if no buffer exists now, one of "size" bytes is created.				If one exists, it is expanded to the next multiple of				"size" larger than the current top-bottom contents.	Notes:						The intent is that you will make "size" the largest				chunk which you will ever need to add in one call,				and stick with that constant size for the rest of				the calls. You must "free( bottom )" when you are				finished with the buffer, or it will stick around				until the program exits.	Problems:		References:		Language:	ansi C	Revisions:	03/10/89	mark wiederspahn	written				16apr91		mw		change									change the way expansion is checked;									previous scheme was conservative in									keeping an extra Lrecl bytes of memory									above the necessary chunk.*/#include "output.h"int big_buffer( bottom, top, size )char	**bottom;		/* buffer limits now */char	**top;int		size;			/* how much to grow it (bytes) */{int		length;			/* how big now */int		err;			/* status */	if( Debug > D_MAX ) fprintf( D_OUT,"[big_buffer] start\n");	if( *bottom > *top )		err = error_handler( FATAL,"[big_buffer] bad args" );	err = FALSE;	if( *bottom == NULL || *top == NULL )	{		if( (*bottom =			(char *)malloc( (unsigned)(size*sizeof(char)) ) ) == NULL )			err = error_handler( FATAL,"[big_buffer] malloc failed" );		*top = *bottom;		length = 0;	}	else	{		length = (int)(*top - *bottom);		size = ( ( (length+(size-1)) / size) + 1) * size;		if( (*bottom =			(char *)realloc( *bottom, (unsigned)size ) ) == NULL )			err = error_handler( FATAL,"[big_buffer] realloc failed" );		*top = *bottom + length*sizeof( char );	}	if( Debug >= D_SOME )		fprintf( D_OUT,"[big_buffer] btls = %d %d %d %d\n",			(int)*bottom,(int)*top,length,size );	if( Debug > D_MAX ) fprintf( D_OUT,"[big_buffer] end\n");	return( err );}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -