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