~ubuntu-branches/ubuntu/raring/maradns/raring

« back to all changes in this revision

Viewing changes to update/1.2.12.01/maradns-1.2.11-tidy_parse.patch

  • Committer: Bazaar Package Importer
  • Author(s): Kai Hendry
  • Date: 2010-01-24 12:17:40 UTC
  • mfrom: (1.1.13 upstream) (10.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20100124121740-a4e1fjobwaouz443
Tags: 1.4.02-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
diff -ur maradns-1.2.12/parse/Csv2_database.c maradns-tidy/parse/Csv2_database.c
2
 
--- maradns-1.2.12/parse/Csv2_database.c        2006-07-25 02:35:26.000000000 -0500
3
 
+++ maradns-tidy/parse/Csv2_database.c  2006-07-25 02:32:05.000000000 -0500
4
 
@@ -95,6 +95,48 @@
5
 
        return new;
6
 
 }
7
 
 
8
 
+void csv2_zap_add_state(csv2_add_state *x) {
9
 
+       int a = 0;
10
 
+       csv2_origin *v, *q;
11
 
+       csv2_rr *y, *z;
12
 
+
13
 
+       /* Get rid of the origin stack */
14
 
+       v = x->ostack;
15
 
+       while(v != 0 && a < 10000) {
16
 
+               js_destroy(v->origin);
17
 
+               q = v->next;
18
 
+               js_dealloc(v);
19
 
+               v = q;
20
 
+               a++;
21
 
+       }
22
 
+       a = 0;
23
 
+
24
 
+       /* Get rid of the buffer of rrs */
25
 
+       y = x->buffer;
26
 
+       while(y != 0 && a < 10000) {
27
 
+               js_destroy(y->query);
28
 
+               js_destroy(y->data);
29
 
+               z = y->next;
30
 
+               js_dealloc(y);
31
 
+               y = z;
32
 
+               a++;
33
 
+       }
34
 
+       a = 0;
35
 
+
36
 
+       /* Get rid of the zone string */
37
 
+       if(x->zone != 0) {
38
 
+               js_destroy(x->zone);
39
 
+               x->zone = 0;
40
 
+       }
41
 
+
42
 
+       /* And now, finally, get rid of this object, I mean structure */
43
 
+       js_dealloc(x);
44
 
+}
45
 
+       
46
 
+/* Function to clean up the memory used by a given csv2_add_state; if this
47
 
+ * were object-oriented, this function would be the deconstructor for the
48
 
+ * csv2_add_state */
49
 
+
50
 
 /* Function to set the big hash we point to 
51
 
  * Input: Pointer to hash
52
 
  * Output: JS_ERROR on error; JS_SUCCESS on success */
53
 
@@ -120,7 +162,8 @@
54
 
 /* Function that closes out the state for processing parsed records;
55
 
  * JS_ERROR on error, JS_SUCCESS on success */
56
 
 int csv2_close_state(csv2_add_state *state) {
57
 
-       return js_dealloc(state);
58
 
+       csv2_zap_add_state(state);
59
 
+       return JS_SUCCESS;
60
 
 }
61
 
 
62
 
 /* Function that uses stat() to determine the timestamp to put in the
63
 
@@ -851,6 +894,10 @@
64
 
                ret = JS_SUCCESS; 
65
 
        }
66
 
        if(ret != JS_ERROR) {
67
 
+               js_dealloc(state->buffer->query); /* This is copied in
68
 
+                                                     csv2_add_rr_w */
69
 
+               js_dealloc(state->buffer->data); /* We finally copy this in 
70
 
+                                                  * mhash_put_rr/mhash_add_rr */
71
 
                js_dealloc(state->buffer);
72
 
                state->buffer = save;
73
 
        }
74
 
diff -ur maradns-1.2.12/parse/Csv2_functions.h maradns-tidy/parse/Csv2_functions.h
75
 
--- maradns-1.2.12/parse/Csv2_functions.h       2006-07-25 02:35:26.000000000 -0500
76
 
+++ maradns-tidy/parse/Csv2_functions.h 2006-07-25 02:08:54.000000000 -0500
77
 
@@ -48,6 +48,10 @@
78
 
  */
79
 
 csv2_add_state *csv2_init_add_state(js_string *zone);
80
 
 
81
 
+/* This function releases the memory resources that the csv2_add_state
82
 
+ * x is using up */
83
 
+void csv2_zap_add_state(csv2_add_state *x);
84
 
+
85
 
 /* Function to set the big hash we point to 
86
 
  * Input: Pointer to hash
87
 
  * Output: JS_ERROR on error; JS_SUCCESS on success */
88
 
diff -ur maradns-1.2.12/parse/Csv2_main.c maradns-tidy/parse/Csv2_main.c
89
 
--- maradns-1.2.12/parse/Csv2_main.c    2006-07-25 02:35:26.000000000 -0500
90
 
+++ maradns-tidy/parse/Csv2_main.c      2006-07-25 02:35:08.000000000 -0500
91
 
@@ -450,6 +450,7 @@
92
 
                printf("Error opening ");
93
 
                show_esc_stdout(filename);
94
 
                printf("\n");
95
 
+               csv2_zap_add_state(state);
96
 
                return 0;
97
 
        }
98
 
 
99
 
@@ -472,25 +473,34 @@
100
 
                unsigned char get[3];
101
 
                if(csv2_tcp_spit_soa(state, connect, header, zone) 
102
 
                                == JS_ERROR) {
103
 
+                       csv2_zap_add_state(state);
104
 
                        return JS_ERROR;
105
 
                }
106
 
                /* Determine how long the next query will be */
107
 
                if(connect == 1) { /* STDIN for inetd hack */
108
 
-                       if(read(0,get,2) != 1)
109
 
+                       if(read(0,get,2) != 1) {
110
 
+                               csv2_zap_add_state(state);
111
 
                                return JS_ERROR;
112
 
+                       }
113
 
                } else {
114
 
-                       if(recv(connect,get,2,0) != 2)
115
 
+                       if(recv(connect,get,2,0) != 2) {
116
 
+                               csv2_zap_add_state(state);
117
 
                                return JS_ERROR;
118
 
+                       }
119
 
                }
120
 
                length = (get[0] & 0xff) << 8 | (get[1] & 0xff);
121
 
                /* Pretend to get the next, actual, query */
122
 
                while(length > 0) {
123
 
                        if(connect == 1) { /* STDIN; for inetd hack */
124
 
-                               if(read(0,get,1) != 1)
125
 
+                               if(read(0,get,1) != 1) {
126
 
+                                       csv2_zap_add_state(state);
127
 
                                        return JS_ERROR;
128
 
+                               }
129
 
                        } else {
130
 
-                               if(recv(connect,get,1,MSG_WAITALL) != 1)
131
 
+                               if(recv(connect,get,1,MSG_WAITALL) != 1) {
132
 
+                                       csv2_zap_add_state(state);
133
 
                                        return JS_ERROR;
134
 
+                               }
135
 
                        }
136
 
                        length--;
137
 
                }
138
 
@@ -506,6 +516,7 @@
139
 
        /* Second, flush the buffer out */
140
 
        if(csv2_tcp_spit_buffer(state,connect,header,zone) == JS_ERROR) {
141
 
                js_dealloc(soa_save);
142
 
+               csv2_zap_add_state(state);
143
 
                return JS_ERROR;
144
 
        }
145
 
 
146
 
@@ -524,6 +535,7 @@
147
 
                if(csv2_tcp_spit_buffer(state,connect,header,zone) == 
148
 
                                JS_ERROR) {
149
 
                        js_dealloc(soa_save);
150
 
+                       csv2_zap_add_state(state);
151
 
                        return JS_ERROR;
152
 
                }
153
 
 
154
 
@@ -537,8 +549,10 @@
155
 
        if(csv2_tcp_spit_data(state,connect,header,zone,3,soa_save) 
156
 
                        == JS_ERROR) {
157
 
                js_dealloc(soa_save);
158
 
+               csv2_zap_add_state(state);
159
 
                return JS_ERROR;
160
 
        }
161
 
+       csv2_zap_add_state(state);
162
 
        return JS_SUCCESS;      
163
 
 
164
 
 }
165
 
@@ -599,6 +613,7 @@
166
 
                printf("Error opening ");
167
 
                show_esc_stdout(filename);
168
 
                printf("\n");
169
 
+               csv2_zap_add_state(state);
170
 
                return 0;
171
 
        }
172
 
 
173
 
@@ -610,6 +625,7 @@
174
 
                }
175
 
        }
176
 
        csv2_close(stream);
177
 
+       csv2_zap_add_state(state);
178
 
        return 0;
179
 
 }
180