Mercurial > hg-old > index.cgi
comparison src/macro.c @ 68:cef25b0088e6
Fixed some problems detected by valgrind and testing
author | lost |
---|---|
date | Mon, 05 Jan 2009 06:14:41 +0000 |
parents | d5fe306f1ab1 |
children | b7550988b97c |
comparison
equal
deleted
inserted
replaced
67:d5fe306f1ab1 | 68:cef25b0088e6 |
---|---|
108 return 0; | 108 return 0; |
109 | 109 |
110 if (as -> passnum == 2) | 110 if (as -> passnum == 2) |
111 return 1; | 111 return 1; |
112 | 112 |
113 as -> macros -> lines = lwasm_realloc(as -> macros -> lines, sizeof(char *) * as -> macros -> numlines + 1); | 113 as -> macros -> lines = lwasm_realloc(as -> macros -> lines, sizeof(char *) * (as -> macros -> numlines + 1)); |
114 as -> macros -> lines[as -> macros -> numlines] = lwasm_strdup(optr); | 114 as -> macros -> lines[as -> macros -> numlines] = lwasm_strdup(optr); |
115 as -> macros -> numlines += 1; | 115 as -> macros -> numlines += 1; |
116 return 1; | 116 return 1; |
117 } | 117 } |
118 | 118 |
185 } | 185 } |
186 p2++; | 186 p2++; |
187 } | 187 } |
188 | 188 |
189 // have arg here | 189 // have arg here |
190 args = lwasm_realloc(args, nargs + 1); | 190 args = lwasm_realloc(args, sizeof(char *) * (nargs + 1)); |
191 args[nargs] = lwasm_alloc(p2 - *p + 1); | 191 args[nargs] = lwasm_alloc(p2 - *p + 1); |
192 args[nargs][p2 - *p] = '\0'; | 192 args[nargs][p2 - *p] = '\0'; |
193 memcpy(args[nargs], *p, p2 - *p); | 193 memcpy(args[nargs], *p, p2 - *p); |
194 *p = p2; | 194 *p = p2; |
195 | 195 |
203 *p3 = *p2; | 203 *p3 = *p2; |
204 } | 204 } |
205 *p3 = '\0'; | 205 *p3 = '\0'; |
206 | 206 |
207 nargs++; | 207 nargs++; |
208 if (**p == ',') | |
209 (*p)++; | |
208 } | 210 } |
209 } | 211 } |
210 | 212 |
211 // step 2: iterate over the lines | 213 // step 2: iterate over the lines |
212 if (as -> passnum == 2) | 214 if (as -> passnum == 2) |
223 { | 225 { |
224 // pass 1 only - construct the lines and parse them | 226 // pass 1 only - construct the lines and parse them |
225 for (lc = 0; lc < m -> numlines; lc++) | 227 for (lc = 0; lc < m -> numlines; lc++) |
226 { | 228 { |
227 nl = lwasm_alloc(sizeof(lwasm_line_t)); | 229 nl = lwasm_alloc(sizeof(lwasm_line_t)); |
228 nl -> text = lwasm_strdup(linebuff); | |
229 nl -> lineno = lc + 1; | 230 nl -> lineno = lc + 1; |
230 nl -> filename = m -> name; | 231 nl -> filename = m -> name; |
231 nl -> next = NULL; | 232 nl -> next = NULL; |
232 nl -> prev = as -> linestail; | 233 nl -> prev = as -> linestail; |
233 nl -> err = NULL; | 234 nl -> err = NULL; |