/*
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
strata_estimator_write (const struct StrataEstimator *se,
void *buf)
{
+ char *sbuf = buf;
unsigned int i;
- void *sbuf = buf;
size_t osize;
GNUNET_assert (NULL != se);
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 nsize;
if (GNUNET_YES ==
- GNUNET_try_compression (sbuf,
+ GNUNET_try_compression (buf,
osize,
&cbuf,
&nsize))
{
- memcpy (sbuf, cbuf, nsize);
+ memcpy (buf, cbuf, nsize);
osize = nsize;
GNUNET_free (cbuf);
}
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;