Line data Source code
1 : #include "../../../burp.h"
2 : #include "../../../alloc.h"
3 : #include "incoming.h"
4 :
5 0 : struct incoming *incoming_alloc(void)
6 : {
7 : return (struct incoming *)calloc_w(1,
8 0 : sizeof(struct incoming), __func__);
9 : }
10 :
11 0 : int incoming_grow_maybe(struct incoming *in)
12 : {
13 0 : if(++in->size<in->allocated) return 0;
14 : // Make the incoming array bigger.
15 0 : in->allocated+=32;
16 : //printf("grow incoming to %d\n", in->allocated);
17 0 : if((in->fingerprints=(uint64_t *)
18 : realloc_w(in->fingerprints,
19 0 : in->allocated*sizeof(uint64_t), __func__))
20 0 : && (in->found=(uint8_t *)
21 0 : realloc_w(in->found, in->allocated*sizeof(uint8_t), __func__)))
22 0 : return 0;
23 0 : return -1;
24 : }
25 :
26 0 : void incoming_found_reset(struct incoming *in)
27 : {
28 0 : if(!in->found || !in->size) return;
29 0 : memset(in->found, 0, sizeof(in->found[0])*in->size);
30 0 : in->got=0;
31 : }
|