示例#1
0
文件: exec.c 项目: moxley/parse1
int exec_close(struct t_exec *exec) {
  struct item *item;
  
  parser_close(&exec->parser);
  
  item = exec->functions.first;
  while (item) {
    func_free(item->value);
    item = item->next;
  }
  list_empty(&exec->functions);

  item = exec->values.first;
  while (item) {
    value_free(item->value);
    item = item->next;
  }
  list_empty(&exec->values);
  
  item = exec->vars.first;
  while (item) {
    var_close(item->value);
    item = item->next;
  }
  list_empty(&exec->vars);

  item = exec->formats.first;
  while (item) {
    var_close(item->value);
    item = item->next;
  }
  list_empty(&exec->formats);
  
  return 0;
}
示例#2
0
int main(void) {
  struct t_parser parser;
  int i;

  if (parser_init(&parser, stdin)) {
    fprintf(stderr, "Failed to initialize parser\n");
    return 1;
  }

  if (parser_count_errors(&parser)) {
    fprintf(stderr, "Failure while counting errors\n");
  }
  else {
    for (i=0; parser.errors[i]; i++) {
      printf("Error %d: %s. Line: %d, Col: %d\n",
      	i+1,
        parse_error_names[parser.errors[i]->token.error],
        parser.errors[i]->token.row + 1,
        parser.errors[i]->token.col + 1);
    }
  }

  parser_close(&parser);
  printf("Done.\n");

  return 0;
}
示例#3
0
void MP4Parser::mp4_free(MP4Context *&mp4)
{
  if (!mp4) return;

  FormatContext *ic = mp4->stream;
  flush_packet_queue(ic);
  for (unsigned i = 0; i < ic->nb_streams; ++i) {
    Stream *st = ic->streams[i];
    if (st->parser) {
      parser_close(st->parser);
      st->parser = NULL;
    }
    SAFE_FREE(st->codec);
    SAFE_FREE(st);
  }
  SAFE_FREE(ic->streams);
  SAFE_FREE(ic);

  SAFE_FREE(mp4);
}