utils.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /**
  2. * @file
  3. * @brief API cghdr.h
  4. * @ingroup cgraph_utils
  5. */
  6. /*************************************************************************
  7. * Copyright (c) 2011 AT&T Intellectual Property
  8. * All rights reserved. This program and the accompanying materials
  9. * are made available under the terms of the Eclipse Public License v1.0
  10. * which accompanies this distribution, and is available at
  11. * https://www.eclipse.org/legal/epl-v10.html
  12. *
  13. * Contributors: Details at https://graphviz.org
  14. *************************************************************************/
  15. #include <cgraph/cghdr.h>
  16. #include <stddef.h>
  17. static Agraph_t *Ag_dictop_G;
  18. void agdictobjfree(void *p) {
  19. Agraph_t *g = Ag_dictop_G;
  20. if (g)
  21. agfree(g, p);
  22. else
  23. free(p);
  24. }
  25. Dict_t *agdtopen(Agraph_t * g, Dtdisc_t * disc, Dtmethod_t * method)
  26. {
  27. return dtopen(disc, method);
  28. }
  29. int agdtdelete(Agraph_t * g, Dict_t * dict, void *obj)
  30. {
  31. Ag_dictop_G = g;
  32. return dtdelete(dict, obj) != NULL;
  33. }
  34. int agdtclose(Agraph_t * g, Dict_t * dict)
  35. {
  36. dtdisc(dict, NULL);
  37. Ag_dictop_G = g;
  38. if (dtclose(dict))
  39. return 1;
  40. Ag_dictop_G = NULL;
  41. return 0;
  42. }
  43. void agdtdisc(Agraph_t * g, Dict_t * dict, Dtdisc_t * disc)
  44. {
  45. (void)g; /* unused */
  46. if (disc && dtdisc(dict, NULL) != disc) {
  47. dtdisc(dict, disc);
  48. }
  49. /* else unchanged, disc is same as old disc */
  50. }
  51. /// @defgroup cgraph_utils utilities
  52. /// @brief low level cgraph utilities
  53. /// @ingroup cgraph