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

📄 instlink.c

📁 这是一个C程序分析工具
💻 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 + -