forked from jwasham/c-note
-
Notifications
You must be signed in to change notification settings - Fork 0
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
2 changed files
with
43 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
#include <limits.h> | ||
|
||
#include "hash-pointer.h" | ||
|
||
/* Hash function for a generic pointer */ | ||
|
||
unsigned int pointer_hash(void *location) | ||
{ | ||
return (unsigned int) (unsigned long) location; | ||
} | ||
|
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,31 @@ | ||
|
||
/** | ||
* @file hash-pointer.h | ||
* | ||
* Hash function for a generic (void) pointer. See @ref pointer_hash. | ||
*/ | ||
|
||
#ifndef ALGORITHM_HASH_POINTER_H | ||
#define ALGORITHM_HASH_POINTER_H | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* Generate a hash key for a pointer. The value pointed at by the pointer | ||
* is not used, only the pointer itself. | ||
* | ||
* @param location The pointer | ||
* @return A hash key for the pointer. | ||
*/ | ||
|
||
unsigned int pointer_hash(void *location); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* #ifndef ALGORITHM_HASH_POINTER_H */ | ||
|
||
|