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

📄 checkfree.c

📁 unix高级编程源代码.<<unix高级编程>>
💻 C
字号:
#include	"db.h"

/* Check the consistency of the free list, and return a count of
   the number of records on the free list.
   This is an undocumented function and should be called when the
   db is not being updated. */

int
_db_checkfree(DB *db)
{
	off_t	offset, nextoffset, saveoffset;
	char	c, *ptr;
	int		count;

		/* Read the free list pointer */
	saveoffset = FREE_OFF;
	offset = _db_readptr(db, saveoffset);

		/* Loop through the free list */
	count = 0;
	while (offset != 0) {
		count++;
		nextoffset = _db_readidx(db, offset);

			/* make certain key is all blank */
		ptr = db->idxbuf;
		while ( (c = *ptr++) != 0)
			if (c != ' ')
				return(-1);	/* error */

			/* make certain data is all blank */
		ptr = _db_readdat(db);
		while ( (c = *ptr++) != 0)
			if (c != ' ')
				return(-1);	/* error */

		saveoffset = offset;
		offset = nextoffset;
	}
	return(count);		/* can be zero */
}

⌨️ 快捷键说明

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