-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
55 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include "pinghostlist.h" | ||
|
||
#include <stddef.h> | ||
#include <stdlib.h> | ||
|
||
void prependPingHost( struct PingHost ** list, unsigned int * listSize, const char * newEntryValue ) | ||
{ | ||
struct PingHost* newEntry = malloc( sizeof(struct PingHost) ); | ||
newEntry->host = newEntryValue; | ||
newEntry->next = *list; | ||
*list = newEntry; | ||
(*listSize) ++; | ||
} | ||
|
||
void freePingHostList( struct PingHost ** list, unsigned int * listSize ) | ||
{ | ||
struct PingHost * current = *list; | ||
while( current ) | ||
{ | ||
struct PingHost * next = current->next; | ||
free( current ); | ||
current = next; | ||
} | ||
*list = NULL; | ||
if(listSize) | ||
{ | ||
*listSize = 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#ifndef PING_HOST_LIST_H | ||
#define PING_HOST_LIST_H | ||
|
||
|
||
// linked list of hosts to ping | ||
struct PingHost | ||
{ | ||
const char * host; | ||
struct PingHost* next; | ||
}; | ||
|
||
// add a new entry to the list | ||
void prependPingHost( struct PingHost ** list, unsigned int * listSize, const char * newEntryValue ); | ||
|
||
// delete the list | ||
// *list and *listsize will be set to 0 | ||
void freePingHostList( struct PingHost ** list, unsigned int * listSize ); | ||
|
||
#endif |