Revision 685225b2

View differences:

streaming.c
269 269
  }
270 270
}
271 271

  
272
int generated_chunk(suseconds_t *delta)
272
struct chunk *generated_chunk(suseconds_t *delta)
273 273
{
274
  int res;
275
  struct chunk c;
274
  struct chunk *c;
275

  
276
  c = malloc(sizeof(struct chunk));
277
  if (!c) {
278
    fprintf(stderr, "Memory allocation error!\n");
279
    return NULL;
280
  }
276 281

  
277
  *delta = input_get(input, &c);
282
  *delta = input_get(input, c);
278 283
  if (*delta < 0) {
279 284
    fprintf(stderr, "Error in input!\n");
280 285
    exit(-1);
281 286
  }
282
  if (c.data == NULL) {
283
    return 0;
287
  if (c->data == NULL) {
288
    free(c);
289
    return NULL;
284 290
  }
285
  dprintf("Generated chunk %d of %d bytes\n",c.id, c.size);
286
  chunk_attributes_fill(&c);
287
  res = cb_add_chunk(cb, &c);
291
  dprintf("Generated chunk %d of %d bytes\n",c->id, c->size);
292
  chunk_attributes_fill(c);
293
  return c;
294
}
295

  
296
int add_chunk(struct chunk *c)
297
{
298
  int res;
299

  
300
  res = cb_add_chunk(cb, c);
288 301
  if (res < 0) {
289
    free(c.data);
290
    free(c.attributes);
302
    free(c->data);
303
    free(c->attributes);
304
    free(c);
305
    return 0;
291 306
  }
292

  
307
  free(c);
293 308
  return 1;
294 309
}
295 310

  
streaming.h
13 13
int source_init(const char *fname, struct nodeID *myID, bool loop);
14 14
void received_chunk(struct nodeID *from, const uint8_t *buff, int len);
15 15
void send_chunk();
16
int generated_chunk(suseconds_t *delta);
16
struct chunk *generated_chunk(suseconds_t *delta);
17
int add_chunk(struct chunk *c);
17 18
struct chunkID_set *get_chunks_to_accept(struct peer *from, const struct chunkID_set *cset_off, int max_deliver, int trans_id);
18 19
void send_offer();
19 20
void send_accepted_chunks(struct peer *to, struct chunkID_set *cset_acc, int max_deliver, int trans_id);

Also available in: Unified diff