📄 init_volume.c
字号:
/*===========================================================================*//* UTIG interim | init_volume.c | Main *//*===========================================================================*//* Name: init_volume.c Purpose: setup/cleanup once per volume global data structures Usage: Input: Output: Externals: Warnings: Errors: Fatals: Called by: Calls to: Algorithm: this routine (at present) frees all memory allocated for all per-volume linked lists: timespan, lvol, logrec lists. It sets the former list indicator to contain only the first tspan, and all others to be logically empty. This activity MUST be done in cooperation with the allocators for these structures, Utilities/make_*.c. Notes: Problems: should probably call subroutines in Utility References: Language: Author: 02/??/89 Mark Wiederspahn Revisions: mm/dd/yy pgmr name change*/#include "output.h"int init_volume( nlvol, l_head, l_tail, ntspan, ts_head, ts_tail, hdr_head, hdr_tail )int *nlvol; /* number of lvol elements on list */struct lvol **l_head; /* head ptr of list */struct lvol **l_tail; /* tail ptr of list */int *ntspan; /* number of tspan elements on list */struct tspan_list **ts_head;struct tspan_list **ts_tail;struct logrec_list **hdr_head;struct logrec_list **hdr_tail;{struct lvol *lp, *lnext;struct tspan_list *tsp, *tsnext;struct logrec_list *hp, *hnext;int err; if( Debug ) fprintf( D_OUT,"[init_volume] start\n"); if( Debug ) fflush( D_OUT );/* * zap lvol list */ if( *nlvol > 0 ) /* if we have any nodes on the list, zap them */ { if( Debug >= D_SOME ) fprintf( D_OUT,"[init_volume] free lvol list\n"); lp = *l_head; while( lp != NULL && (*nlvol)-- ) { lnext = lp->next; if( Debug >= D_MAX ) fprintf( D_OUT,"[init_volume] lvol: %d %d\n", (int)lp, (int)lnext ); free( lp ); /* give the node's memory back */ lp = lnext; } if( lp != NULL || *nlvol != 0 ) error_handler( ERROR,"[init_volume] lvol list inconsistency");#ifdef MALLOC_DEBUG if( !malloc_verify() ) error_handler( ERROR,"[init_volume] lvol list bad");#endif } *l_head = *l_tail = NULL; *nlvol = 0; /* no nodes on list *//* * zap tspan list, except for one node we leave on it as first of this tspan */ if( *ntspan > 0 ) /* same for timespan nodes */ { if( Debug >= D_SOME ) fprintf( D_OUT,"[init_volume] free tspan list\n"); tsp = *ts_head; while( tsp != NULL && (*ntspan)-- ) { tsnext = tsp->next; if( Debug >= D_MAX ) fprintf( D_OUT,"[init_volume] tspan: %d %d\n", (int)tsp, (int)tsnext ); free( tsp ); /* give the node's memory back */ tsp = tsnext; } if( tsp != NULL || *ntspan != 0 ) error_handler( ERROR,"[init_volume] tspan list inconsistency");#ifdef MALLOC_DEBUG if( !malloc_verify() ) error_handler( ERROR,"[init_volume] tspan list bad");#endif } *ts_head = *ts_tail = NULL; /* make the list empty */ (void)make_tspan( ts_head, ts_tail ); *ntspan = 1; /* one node on list *//* * zap headers list */ if( Debug >= D_SOME ) fprintf( D_OUT,"[init_volume] free hdrs list\n"); hp = *hdr_head; while( hp != NULL ) { hnext = hp->next; if( Debug >= D_MAX ) fprintf( D_OUT,"[init_volume] hdrs: %d %d %d\n", (int)hp, (int)hp->record, (int)hnext ); free( hp->record ); /* logical record buffer */#ifdef MALLOC_DEBUG if( !malloc_verify() ) error_handler( ERROR,"[init_volume] hdr list bad");#endif free( hp ); hp = hnext;#ifdef MALLOC_DEBUG if( !malloc_verify() ) error_handler( ERROR,"[init_volume] hdr list bad");#endif } *hdr_head = *hdr_tail = NULL; if( Debug ) fprintf( D_OUT,"[init_volume] end\n"); if( Debug ) fflush( D_OUT );}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -