📄 make_room.c
字号:
/*===========================================================================*//* DMC interim out | make_room.c | Utility *//*===========================================================================*//* Name: make_room.c Purpose: make large contiguous dynamic buffers Usage: make_room( length, extra, bottom, top ) Input: int length size of allocation now int extra size it is to be extended char *bottom bottom of existing buffer or NULL char *top top of used part of buffer or NULL top may or may not be == bottom+len. Output: none, may die here if memory allocation fails. Externals: Warnings: Errors: Fatals: allocation error Called by: Calls to: Algorithm: if no buffer exists now, one is created. If one exists, it is expanded to fit at least length+extra. Notes: Problems: References: Language: ansi C Revisions: 21apr91 mark wiederspahn written derived from big_buffer, which is no longer used.*/#include "output.h"void make_room( length, extra, bottom, top )int length;int extra;char **bottom;char **top;{ int err; if( Debug > D_MAX ) fprintf( D_OUT,"[make_room] start\n"); if( *bottom > *top || length < 0 || extra < 0 ) err = error_handler( FATAL,"[make_room] bad args" ); if( *bottom == NULL || *top == NULL ) { if( (*bottom = (char *)malloc((unsigned)(length+extra+1))) == NULL ) err = error_handler( FATAL,"[make_room] malloc failed" ); *top = *bottom; } else { if( (*bottom = (char *)realloc(*bottom, (unsigned)(length+extra+1))) == NULL ) err = error_handler(FATAL,"[make_room] realloc failed"); *top = *bottom + length*sizeof(char); } if( Debug >= D_SOME ) fprintf( D_OUT,"[make_room] btle = %d %d %d %d\n", (int)*bottom,(int)*top,length,extra ); if( Debug > D_MAX ) fprintf( D_OUT,"[make_room] end\n");}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -