示例#1
0
HYPRE_Int 
HYPRE_SStructSplitDestroy( HYPRE_SStructSolver solver )
{
   hypre_SStructVector     *y;
   HYPRE_Int                nparts;
   HYPRE_Int               *nvars;
   void                 ****smatvec_data;
   HYPRE_Int            (***ssolver_solve)();
   HYPRE_Int            (***ssolver_destroy)();
   void                  ***ssolver_data;

   HYPRE_Int              (*sdestroy)();
   void                    *sdata;

   HYPRE_Int                part, vi, vj;

   if (solver)
   {
      y               = (solver -> y);
      nparts          = (solver -> nparts);
      nvars           = (solver -> nvars);
      smatvec_data    = (solver -> smatvec_data);
      ssolver_solve   = (solver -> ssolver_solve);
      ssolver_destroy = (solver -> ssolver_destroy);
      ssolver_data    = (solver -> ssolver_data);

      HYPRE_SStructVectorDestroy(y);
      for (part = 0; part < nparts; part++)
      {
         for (vi = 0; vi < nvars[part]; vi++)
         {
            for (vj = 0; vj < nvars[part]; vj++)
            {
               if (smatvec_data[part][vi][vj] != NULL)
               {
                  hypre_StructMatvecDestroy(smatvec_data[part][vi][vj]);
               }
            }
            hypre_TFree(smatvec_data[part][vi]);
            sdestroy = ssolver_destroy[part][vi];
            sdata = ssolver_data[part][vi];
            sdestroy(sdata);
         }
         hypre_TFree(smatvec_data[part]);
         hypre_TFree(ssolver_solve[part]);
         hypre_TFree(ssolver_destroy[part]);
         hypre_TFree(ssolver_data[part]);
      }
      hypre_TFree(nvars);
      hypre_TFree(smatvec_data);
      hypre_TFree(ssolver_solve);
      hypre_TFree(ssolver_destroy);
      hypre_TFree(ssolver_data);
      hypre_SStructMatvecDestroy(solver -> matvec_data);
      hypre_TFree(solver);
   }

   return hypre_error_flag;
}
示例#2
0
文件: _yappi.c 项目: sumerc/yappi
// context will be cleared by the free list. we do not free it here.
// we only free the context call stack.
static void
_del_ctx(_ctx * ctx)
{
    sdestroy(ctx->cs);
    htdestroy(ctx->rec_levels);
    henum(ctx->pits, _pitenumdel, NULL);
    htdestroy(ctx->pits);
    Py_CLEAR(ctx->name);
}
示例#3
0
int main(int argc, char **argv) {
  int fd;
  sexp_t *sx;
  sexp_iowrap_t *iow;
  int diff;
  unsigned int i;
  int ch;
  char fname[BUFSIZ];
  CSTRING *s1,*s2;
  int passes, failures;
  char outbuf1[8192], outbuf2[8192];
  
  s1 = s2 = NULL;
  passes = failures = 0;

  strcpy(fname,TESTFILE);

  while ((ch = getopt(argc,argv,"f:")) != -1) {
    switch ((char)ch) {
    case 'f':
      strcpy(fname,optarg);
      break;
    default:
      break;
    }
  }

  fd = open(fname,O_RDONLY);

  iow = init_iowrap(fd);

  printf("TESTING CSTRING BASED UNPARSE:\n");
  
  sx = read_one_sexp(iow);

  while (sx != NULL) {

    print_sexp_cstr(&s1,sx,8);
    destroy_sexp(sx);
    
    sx = parse_sexp(s1->base,s1->curlen);
    if (sx == NULL) {
      fprintf(stderr,"ERROR: parser error state of %d\n",
	      sexp_errno);
      exit(1);
    }
    print_sexp_cstr(&s2,sx,8);
    destroy_sexp(sx);
    
    sexp_cleanup();

    diff = 0;
    for (i=0;i<s1->curlen;i++) {
      diff += abs((s1->base[i] - s2->base[i]));
      if (s1->base[i] == '\0')
        break;
    }
        
    /**
     * diff is the lexical difference between the first unparsing
     * of the original buffer and the unparsed version of the parsed
     * version of the first unparsed string.  In other words, does:
     * 
     *   orig->parse->unparse == orig->parse->unparse->parse->unparse
     *
     * This catches issues with print and parse to make sure the meaning
     * of the original is kept (or at least, "bugs" in the parser have
     * matching "bugs" in the printer.)
     */
    if (diff != 0) {
      printf("FIXED POINT MISSED (diff=%d): \nS1: %s\nS2: %s\n",diff,
             s1->base,s2->base);
      failures++;
    } else {
      passes++;
    }

    /** clean up strings **/
    sdestroy(s1);
    sdestroy(s2);
    s1 = s2 = NULL;

    sx = read_one_sexp(iow);
  }
  
  destroy_iowrap(iow);
  close(fd);
  
  printf("TOTAL TESTS: %d  PASS=%d FAIL=%d\n\n",
          passes+failures,passes,failures);

  passes = failures = 0;

  /***
   *** now do normal fixed length buffer unparse testing
   ***/
  fd = open(fname,O_RDONLY);

  iow = init_iowrap(fd);

  printf("TESTING FIXED SIZE BUFFER BASED UNPARSE:\n");
  
  sx = read_one_sexp(iow);

  while (sx != NULL) {
    print_sexp(outbuf1,8192,sx);
    destroy_sexp(sx);
    
    sx = parse_sexp(outbuf1,8192);
    if (sx == NULL) {
      fprintf(stderr,"ERROR: parser error state of %d\n",
	      sexp_errno);
      exit(1);
    }
    print_sexp(outbuf2,8192,sx);
    destroy_sexp(sx);
    
    sexp_cleanup();

    diff = 0;
    for (i=0;i<8192;i++) {
      diff += abs((outbuf1[i] - outbuf2[i]));
      if (outbuf1[i] == '\0' || outbuf2[i] == '\0')
        break;
    }
        
    /**
     * diff is the lexical difference between the first unparsing
     * of the original buffer and the unparsed version of the parsed
     * version of the first unparsed string.  In other words, does:
     * 
     *   orig->parse->unparse == orig->parse->unparse->parse->unparse
     *
     * This catches issues with print and parse to make sure the meaning
     * of the original is kept (or at least, "bugs" in the parser have
     * matching "bugs" in the printer.)
     */
    if (diff != 0) {
      printf("FIXED POINT MISSED (diff=%d): \nS1: %s\nS2: %s\n",diff,
             outbuf1,outbuf2);
      failures++;
    } else {
      passes++;
    }

    sx = read_one_sexp(iow);
  }
  
  destroy_iowrap(iow);
  close(fd);

  printf("TOTAL TESTS: %d  PASS=%d FAIL=%d\n",
          passes+failures,passes,failures);

  exit(0);
}