summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2009-08-04 15:33:53 -0600
committerBrian Paul <brianp@vmware.com>2009-08-04 15:36:28 -0600
commit9f8110adcc5a6f47b5db0915bb9265925d520856 (patch)
tree58a9969a2a4a6e62ebfb11a6d12b3eda3a8f277d /src
parent84c8315ae66f34466d0f7b9db8a825c15e0594a8 (diff)
mesa: added _mesa_str_checksum()
Diffstat (limited to 'src')
-rw-r--r--src/mesa/main/imports.c14
-rw-r--r--src/mesa/main/imports.h3
2 files changed, 17 insertions, 0 deletions
diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c
index 8967bb3dd5..6ffaddcde9 100644
--- a/src/mesa/main/imports.c
+++ b/src/mesa/main/imports.c
@@ -911,6 +911,20 @@ _mesa_strtod( const char *s, char **end )
return strtod(s, end);
}
+/** Compute simple checksum/hash for a string */
+unsigned int
+_mesa_str_checksum(const char *str)
+{
+ /* This could probably be much better */
+ unsigned int sum, i;
+ const char *c;
+ sum = i = 1;
+ for (c = str; *c; c++)
+ sum += *c * (i % 100);
+ return sum;
+}
+
+
/*@}*/
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index 7b61e22e93..fb85f0862c 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -586,6 +586,9 @@ _mesa_atoi( const char *s );
extern double
_mesa_strtod( const char *s, char **end );
+extern unsigned int
+_mesa_str_checksum(const char *str);
+
extern int
_mesa_sprintf( char *str, const char *fmt, ... );