diff options
Diffstat (limited to 'src/compression/dict.c')
-rw-r--r-- | src/compression/dict.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/compression/dict.c b/src/compression/dict.c index 24e6ae7..fdfe7a0 100644 --- a/src/compression/dict.c +++ b/src/compression/dict.c @@ -1,7 +1,7 @@ /* This code is part of the tng compression routines. * - * Written by Daniel Spangberg - * Copyright (c) 2010, 2013, The GROMACS development team. + * Written by Daniel Spangberg and Magnus Lundborg + * Copyright (c) 2010, 2013-2014 The GROMACS development team. * * * This program is free software; you can redistribute it and/or @@ -17,6 +17,7 @@ void Ptngc_comp_canonical_dict(unsigned int *dict, int *ndict) int i; for (i=0; i<0x20004; i++) dict[i]=i; + *ndict=0x20004; } @@ -26,18 +27,19 @@ void Ptngc_comp_make_dict_hist(unsigned int *vals, int nvals, { int i; int j=0; - for (i=0; i<0x20004; i++) - hist[i]=0; - for (i=0; i<0x20004; i++) - dict[i]=i; + + memset(hist, 0, sizeof(unsigned int)*0x20004); + for (i=0; i<nvals; i++) hist[vals[i]]++; for (i=0; i<0x20004; i++) if (hist[i]!=0) { hist[j]=hist[i]; - dict[j]=dict[i]; + dict[j]=i; j++; + if(j==nvals) + break; } *ndict=j; } |