Пример #1
0
long treestack_push(Dataptr matrix, Treestack *sp, const Branch *const barray, const long root)
{
    long i;			/* loop counter */
    Branch *stacktree = NULL;	/* current tree on stack */
    long stackroot;		/* root of current tree */

    /* return before push if not a new topology */
    /* check backwards as similar trees may be discovered together */
    for (i = sp->next - 1; i >= 0; i--) {
        stacktree = sp->stack[i].tree;
        stackroot = sp->stack[i].root;
        if (treecmp(matrix, stacktree, stackroot, barray, root) == 0) return 0;
    }

    /* topology is new so must be pushed */
    dopush(matrix, sp, barray, root);
    return 1;

} /* end treestack_push() */
Пример #2
0
void stringStackOptimize(poffHandle_t poffHandle,
                         poffProgHandle_t poffProgHandle)
{
  int i;

  /* Allocate an array of buffers to hold pcode data */

  for (i = 0; i < NPBUFFERS; i++)
    {
      pbuffer[i] = (uint8_t*)malloc(PBUFFER_SIZE);
      if (pbuffer[i] == NULL)
        {
          printf("Failed to allocate pcode buffer\n");
          exit(1);
        }
      nbytes_in_pbuffer[i] = 0;
    }

  /* Prime the search logic */

  inch = poffGetProgByte(poffHandle);
  current_level = -1;

  /* And parse the input file to the output file, removing unnecessary string
   * stack operations.
   */

  dopush(poffHandle, poffProgHandle);

  /* Release the buffers */

  for (i = 0; i < NPBUFFERS; i++)
    {
      free(pbuffer[i]);
      pbuffer[i] = NULL;
      nbytes_in_pbuffer[i] = 0;
    }
}