Ejemplo n.º 1
0
void vertex_destroy_void(void *v)
{
    // Sanity check parameters
  assert(v);

    // Call type specific destroy function
  vertex_destroy((vertex_s *)v);
}
Ejemplo n.º 2
0
Archivo: graph.c Proyecto: emilio/gii-2
void graph_destroy(graph_t* self) {
    size_t i;

    for (i = 0; i < self->size; ++i)
        vertex_destroy(self->v[i]);

    free(self->v);
    free(self);
}
Ejemplo n.º 3
0
void quad_destroy(Quad *q)
{
	if (q->verts)
		free(q->verts);
	for (int f = 0; f < 4; f++)
		if (q->tmpVerts[f])
			vertex_destroy(q->tmpVerts[f]);

	free(q);
}
/* Remove a vertex and all its references. */
void
graph_destroyVertex (Graph g, Vid id)
{
  Vertex v = vertex_getFromId (g->vertices, id);

  assert (!element_null (g));
  if (!element_null (v))
    {
      graph_dESTROYvERTEXrEFERENCES (g, v);
      vertex_destroy (v);
    }
}
static void
graph_dESTROYvERTEXlIST (Graph g)
{
  list vertices = g->vertices;
  Vertex v = list_head (vertices);

  assert (!element_null (g));
  while (!list_null (vertices))
    {
      v = list_head (vertices);
      graph_dESTROYvERTEXrEFERENCES (g, v);
      vertex_destroy (v);
      vertices = list_next (vertices);
    }
}
Ejemplo n.º 6
0
design_tolerance_s *design_tolerance_sieve(FILE *infile, FILE *outfile)
{
  doc_list_s *dl;
  design_tolerance_s *t = NULL;
  vertex_s *vertex = NULL;
  design_defaults_s *defaults = NULL;
  int i;
  xmlDocPtr doc;
  xmlNodePtr root;
  int have_one = 0;

  if (!infile) return NULL;

  dl = doc_list_create(infile,
                    "<?xml[^<]*?>",
                    "<tolerance[^<]*>.*</tolerance>"
                    "|<vertex[^<]*/>"
                    "|<defaults[^<]*>.*</defaults>");
  if (!dl) return NULL;

    // Process any matching XML documents

  for (i = 0; i < dl->nkeep; i++)
  {
    doc = xmlReadMemory(dl->keep[i], strlen(dl->keep[i]), NULL, "UTF-8", 0);
    if (doc)
    {
      root = xmlDocGetRootElement(doc);
      if (root)
      {
        if (!strcmp((char *)root->name, "tolerance"))
        {
          if (!have_one &&
              (sieve_get_process_mode() == sieve_process_mode_type_edit))
          {
            have_one = 1;
            t = design_tolerance_from_xml_doc(doc);
            if (t) doc_list_consume(dl, dl->keep[i]);
          }
        }
        else if (!strcmp((char *)root->name, "vertex"))
        {
          vertex = vertex_from_xml_doc(doc);
          if (vertex)
          {
            if (!strcmp((char *)xmlGetProp(root, BAD_CAST "tag"), "location"))
            {
              if (!t) t = design_tolerance_create();
              if (t->location) vertex_destroy(t->location);
              t->location = vertex;
              doc_list_consume(dl, dl->keep[i]);
            }
          }
        }
        else if (!strcmp((char *)root->name, "defaults"))
        {
          defaults = design_defaults_from_xml_doc(doc);
          if (defaults)
          {
            design_defaults_push(defaults);
            doc_list_consume(dl, dl->keep[i]);
          }
        }
      }
      xmlFreeDoc(doc);
    }
  }

    // Emit all non-matching XML documents

  if (outfile)
  {
    for (i = 0; i < dl->nlist; i++)
    {
      if (!dl->list[i]) continue;
      doc = xmlReadMemory(dl->list[i], strlen(dl->list[i]), NULL, "UTF-8", 0);
      if (doc)
      {
        xmlDocFormatDumpEnc(outfile, doc, "UTF-8", 1);
        xmlFreeDoc(doc);
      }
    }
  }

    // Return RETVAL
  return t;
}
Ejemplo n.º 7
0
int main() {
  Vertex* vertex = vertex_create(8);
  vertex_destroy(vertex);
  return 0;
}