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

📄 ntfy_node.c

📁 操作系统SunOS 4.1.3版本的源码
💻 C
字号:
#ifndef	lint#ifdef sccsstatic	char sccsid[] = "@(#)ntfy_node.c 1.1 92/07/30 Copyr 1985 Sun Micro";#endif#endif /* * Copyright (c) 1985 by Sun Microsystems, Inc. *//* * Ntfy_node.c - Storage management for the notifier. */#include <sunwindow/ntfy.h>pkg_private_data int	ntfy_nodes_avail = 0;	/* Count of nodes in ntfy_node_free */pkg_private_data int	ntfy_node_blocks = 0;	/* Count of trips to heap for nodes					   (used for statistics & possibly					   run away process detection) */static	NTFY_NODE *ntfy_node_free;	/* List of free nodes *//* * Caller must initialize data returned from ntfy_alloc_node. * NTFY_NODE_NULL is possible. */pkg_private NTFY_NODE *ntfy_alloc_node(){	NTFY_NODE *node;	if (ntfy_node_free == NTFY_NODE_NULL) {		if (NTFY_IN_INTERRUPT)			return(NTFY_NODE_NULL);		else			ntfy_replenish_nodes();	}	NTFY_BEGIN_CRITICAL;	/* Protect node pool */	if (ntfy_node_free == NTFY_NODE_NULL) {		ntfy_set_errno(NOTIFY_NOMEM);		NTFY_END_CRITICAL;		return(NTFY_NODE_NULL);	}	ntfy_assert(ntfy_nodes_avail > 0, "Node count wrong");	node = ntfy_node_free;	ntfy_node_free = ntfy_node_free->n.next;	ntfy_nodes_avail--;	NTFY_END_CRITICAL;	return(node);}pkg_private voidntfy_replenish_nodes(){	extern	char *calloc();	register NTFY_NODE *new_nodes, *node;	ntfy_assert(!NTFY_IN_INTERRUPT, "Interrupt access to heap");	ntfy_assert(ntfy_nodes_avail <= NTFY_PRE_ALLOCED,	    "Unnecessary node replenishment");	new_nodes = (NTFY_NODE *) calloc(	    1, NTFY_NODES_PER_BLOCK*sizeof(NTFY_NODE));	for (node = new_nodes;node < new_nodes+NTFY_NODES_PER_BLOCK;node++)		ntfy_free_node(node);	ntfy_node_blocks++;}pkg_private voidntfy_free_node(node)	register NTFY_NODE *node;{	NTFY_BEGIN_CRITICAL;	/* Protect node pool */	node->n.next = ntfy_node_free;	ntfy_node_free = node;	ntfy_nodes_avail++;	NTFY_END_CRITICAL;}

⌨️ 快捷键说明

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