From f88d80bb0ad72cdf4afde02467f9d8afdda19d64 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Fri, 17 Feb 2017 10:05:57 +0100 Subject: [PATCH] dead store-- + rewrite of hash function --- teshsuite/smpi/macro-shared/macro-shared.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/teshsuite/smpi/macro-shared/macro-shared.c b/teshsuite/smpi/macro-shared/macro-shared.c index f3ac8488b5..a9f1e5642f 100644 --- a/teshsuite/smpi/macro-shared/macro-shared.c +++ b/teshsuite/smpi/macro-shared/macro-shared.c @@ -13,18 +13,23 @@ static void* hash(char *str, uint64_t* ans) { + char *tohash = str; *ans=5381; int c; printf("hashing !\n"); - while ((c = *str++)!=0) + c = *tohash++; + while (c!=0){ *ans = ((*ans << 5) + *ans) + c; /* hash * 33 + c */ + c = *tohash++; + } return NULL; } int main(int argc, char *argv[]) { MPI_Init(&argc, &argv); - int rank, size; + int rank; + int size; MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &size); //Let's Allocate a shared memory buffer @@ -50,7 +55,6 @@ int main(int argc, char *argv[]) printf("[%d] After change, the value in the shared buffer is: %" PRIu64"\n", rank, *buf); SMPI_SHARED_FREE(buf); - buf=NULL; free(str); MPI_Finalize(); -- 2.20.1