aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/net/bpf_exp.y27
1 files changed, 20 insertions, 7 deletions
diff --git a/tools/net/bpf_exp.y b/tools/net/bpf_exp.y
index f524110643bb..d15efc989ef5 100644
--- a/tools/net/bpf_exp.y
+++ b/tools/net/bpf_exp.y
@@ -40,8 +40,8 @@ extern void yyerror(const char *str);
40 40
41extern void bpf_asm_compile(FILE *fp, bool cstyle); 41extern void bpf_asm_compile(FILE *fp, bool cstyle);
42static void bpf_set_curr_instr(uint16_t op, uint8_t jt, uint8_t jf, uint32_t k); 42static void bpf_set_curr_instr(uint16_t op, uint8_t jt, uint8_t jf, uint32_t k);
43static void bpf_set_curr_label(const char *label); 43static void bpf_set_curr_label(char *label);
44static void bpf_set_jmp_label(const char *label, enum jmp_type type); 44static void bpf_set_jmp_label(char *label, enum jmp_type type);
45 45
46%} 46%}
47 47
@@ -573,7 +573,7 @@ txa
573 573
574static int curr_instr = 0; 574static int curr_instr = 0;
575static struct sock_filter out[BPF_MAXINSNS]; 575static struct sock_filter out[BPF_MAXINSNS];
576static const char **labels, **labels_jt, **labels_jf, **labels_k; 576static char **labels, **labels_jt, **labels_jf, **labels_k;
577 577
578static void bpf_assert_max(void) 578static void bpf_assert_max(void)
579{ 579{
@@ -594,13 +594,13 @@ static void bpf_set_curr_instr(uint16_t code, uint8_t jt, uint8_t jf,
594 curr_instr++; 594 curr_instr++;
595} 595}
596 596
597static void bpf_set_curr_label(const char *label) 597static void bpf_set_curr_label(char *label)
598{ 598{
599 bpf_assert_max(); 599 bpf_assert_max();
600 labels[curr_instr] = label; 600 labels[curr_instr] = label;
601} 601}
602 602
603static void bpf_set_jmp_label(const char *label, enum jmp_type type) 603static void bpf_set_jmp_label(char *label, enum jmp_type type)
604{ 604{
605 bpf_assert_max(); 605 bpf_assert_max();
606 switch (type) { 606 switch (type) {
@@ -717,12 +717,25 @@ static void bpf_init(void)
717 assert(labels_k); 717 assert(labels_k);
718} 718}
719 719
720static void bpf_destroy_labels(void)
721{
722 int i;
723
724 for (i = 0; i < curr_instr; i++) {
725 free(labels_jf[i]);
726 free(labels_jt[i]);
727 free(labels_k[i]);
728 free(labels[i]);
729 }
730}
731
720static void bpf_destroy(void) 732static void bpf_destroy(void)
721{ 733{
722 free(labels); 734 bpf_destroy_labels();
723 free(labels_jt); 735 free(labels_jt);
724 free(labels_jf); 736 free(labels_jf);
725 free(labels_k); 737 free(labels_k);
738 free(labels);
726} 739}
727 740
728void bpf_asm_compile(FILE *fp, bool cstyle) 741void bpf_asm_compile(FILE *fp, bool cstyle)