/*
This file is part of GNUnet
- Copyright (C) 2012 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2012 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
* Should we try compressing the strata estimator? This will
* break compatibility with the 0.10.1-network.
*/
-#define FAIL_10_1_COMPATIBILTIY 0
+#define FAIL_10_1_COMPATIBILTIY 1
/**
strata_estimator_write (const struct StrataEstimator *se,
void *buf)
{
+ char *sbuf = buf;
unsigned int i;
+ size_t osize;
GNUNET_assert (NULL != se);
for (i = 0; i < se->strata_count; i++)
ibf_write_slice (se->strata[i],
0,
se->ibf_size,
- buf);
- buf += se->ibf_size * IBF_BUCKET_SIZE;
+ &sbuf[se->ibf_size * IBF_BUCKET_SIZE * i]);
}
osize = se->ibf_size * IBF_BUCKET_SIZE * se->strata_count;
#if FAIL_10_1_COMPATIBILTIY
{
- size_t osize;
char *cbuf;
size_t nsize;
GNUNET_free_non_null (dbuf);
return GNUNET_SYSERR;
}
+
for (i = 0; i < se->strata_count; i++)
{
ibf_read_slice (buf, 0, se->ibf_size, se->strata[i]);
se->strata[i] = ibf_create (ibf_size, ibf_hashnum);
if (NULL == se->strata[i])
{
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to allocate memory for strata estimator\n");
for (j = 0; j < i; j++)
ibf_destroy (se->strata[i]);
GNUNET_free (se);
c = GNUNET_new (struct StrataEstimator);
c->strata_count = se->strata_count;
c->ibf_size = se->ibf_size;
- c->strata = GNUNET_malloc (sizeof (struct InvertibleBloomFilter *) * se->strata_count);
+ c->strata = GNUNET_new_array (se->strata_count,
+ struct InvertibleBloomFilter *);
for (i = 0; i < se->strata_count; i++)
c->strata[i] = ibf_dup (se->strata[i]);
return c;