From 9f8110adcc5a6f47b5db0915bb9265925d520856 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 4 Aug 2009 15:33:53 -0600 Subject: [PATCH] mesa: added _mesa_str_checksum() --- src/mesa/main/imports.c | 14 ++++++++++++++ src/mesa/main/imports.h | 3 +++ 2 files changed, 17 insertions(+) diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c index 8967bb3dd58..6ffaddcde96 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 7b61e22e932..fb85f0862c6 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, ... ); -- 2.30.2