?? instlink.c
字號:
/*===================================================================
FILE : @(#)instlink.c 2.2 - 08/04/99
===================================================================*/
/*===================================================================
PURPOSE: Provides functions for maintaining a linked list structure.
SYSTEM : RECON II
-------------------------------------------------------------------*/
/*==[ INCLUDES ]=====================================================*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "r2.h"
#include "r2inst.h"
#include "instlink.h"
#include "vb_print.h"
/*===================================================================
FUNCTION: AddNode
===================================================================
PURPOSE : Allocates memory for a Node structure
CALLS : None
USED BY : ParseMultipleFiles
HISTORY :
VER DATE AUTHOR DESCRIPTION
1.00 28 Feb 93 L. McCallie Created file.
-------------------------------------------------------------------*/
void AddNode(ppNode Head, ppNode Tail)
{
pNode New;
New = (pNode) malloc (sizeof (Node));
if (NULL != *Tail)
{
(*Tail)->Next = New;
}
if (NULL == *Head)
{
*Head = New;
}
*Tail = New;
(*Tail)->Next = NULL;
}
/*===================================================================
FUNCTION: FreeList
===================================================================
PURPOSE : Frees memory previously allocated
CALLS : None
USED BY : ParseMultiple Files
HISTORY :
VER DATE AUTHOR DESCRIPTION
1.00 28 Feb 93 L. McCallie Created file.
1.01 1 Mar 93 L. Richard Error in algorithm corrected.
-------------------------------------------------------------------*/
void FreeList(pNode Head)
{
pNode Ptr; /* Temporary node marker */
while (NULL != Head) /* If non-empty list */
{
Ptr = Head; /* Mark node to delete */
Head = Head->Next; /* Mark new top of list */
free(Ptr); /* Remove old top node */
}
}
/*===================================================================
FUNCTION: ShowList
===================================================================
PURPOSE : Displays the linked list contents
CALLS : None
USED BY : ParseMultipleFiles
HISTORY :
VER DATE AUTHOR DESCRIPTION
1.00 28 Feb 93 L. McCallie Created file.
-------------------------------------------------------------------*/
void ShowList (pNode Head)
{
pNode Ptr;
Ptr = Head;
while (NULL != Ptr)
{
vb_print(ADMIN_LEVEL,"File Index: %3d Source File: %s\n",
Ptr->Index, Ptr->Path);
Ptr = Ptr->Next;
}
}
/*===================================================================
FUNCTION: RemoveUnused
===================================================================
PURPOSE : Frees unused links.
CALLS : None
USED BY : ParseMultiple Files
HISTORY :
VER DATE AUTHOR DESCRIPTION
1.00 02 Dec 95 B. Miller Created function.
-------------------------------------------------------------------*/
void RemoveUnused(ppNode Head)
{
pNode Ptr; /* Temporary node marker */
pNode prevHead; /* previous head of the list */
pNode listHead;
prevHead = *Head;
listHead = *Head;
while (NULL != listHead) /* If non-empty list */
{
if ((listHead == *Head) && ((*Head)->Index == 0))
{
Ptr = listHead;
*Head = Ptr->Next;
prevHead = *Head;
listHead = *Head;
Ptr->Next = NULL;
free(Ptr);
}
else if (0 == listHead->Index)
{
Ptr = listHead;
listHead = listHead->Next;
prevHead->Next = listHead;
free(Ptr);
}
else
{
prevHead = listHead;
listHead = listHead->Next;
}
} /* end while */
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -