| 288 | } |
| 289 | |
| 290 | struct flashmap_descriptor *fmd_create(FILE *stream) |
| 291 | { |
| 292 | assert(stream); |
| 293 | |
| 294 | yyin = stream; |
| 295 | |
| 296 | struct flashmap_descriptor *ret = NULL; |
| 297 | if (yyparse() == 0) |
| 298 | ret = res; |
| 299 | |
| 300 | yylex_destroy(); |
| 301 | yyin = NULL; |
| 302 | res = NULL; |
| 303 | |
| 304 | if (ret) { |
| 305 | // This hash table is used to store the declared name of each |
| 306 | // section and ensure that each is globally unique. |
| 307 | if (!hcreate(fmd_count_nodes(ret))) { |
| 308 | perror("E: While initializing hashtable"); |
| 309 | fmd_cleanup(ret); |
| 310 | return NULL; |
| 311 | } |
| 312 | |
| 313 | // Even though we haven't checked that the root node (ret) has |
| 314 | // a size field as required by this function, the parser |
| 315 | // warrants that it does because the grammar requires it. |
| 316 | if (!validate_and_complete_info(ret)) { |
| 317 | hdestroy(); |
| 318 | fmd_cleanup(ret); |
| 319 | return NULL; |
| 320 | } |
| 321 | |
| 322 | hdestroy(); |
| 323 | } |
| 324 | |
| 325 | return ret; |
| 326 | } |
| 327 | |
| 328 | void fmd_cleanup(struct flashmap_descriptor *victim) |
| 329 | { |
no test coverage detected