Graphviz 12.0.1~dev.20240715.2254
Loading...
Searching...
No Matches
mem.c
Go to the documentation of this file.
1
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
16#include <cgraph/cghdr.h>
17#include <stdlib.h>
18
19void *agalloc(Agraph_t * g, size_t size)
20{
21 (void)g;
22
23 void *mem = calloc(1, size);
24 if (mem == NULL)
25 agerrorf("memory allocation failure");
26 return mem;
27}
28
29void *agrealloc(Agraph_t * g, void *ptr, size_t oldsize, size_t size)
30{
31 void *mem;
32
33 if (size > 0) {
34 if (ptr == 0)
35 mem = agalloc(g, size);
36 else {
37 mem = realloc(ptr, size);
38 if (mem != NULL && size > oldsize) {
39 memset((char*)mem + oldsize, 0, size - oldsize);
40 }
41 }
42 if (mem == NULL)
43 agerrorf("memory re-allocation failure");
44 } else
45 mem = NULL;
46 return mem;
47}
48
49void agfree(Agraph_t * g, void *ptr)
50{
51 (void)g;
52
53 if (ptr)
54 free(ptr);
55}
cgraph.h additions
void free(void *)
node NULL
Definition grammar.y:149
void * agalloc(Agraph_t *g, size_t size)
Definition mem.c:19
void agfree(Agraph_t *g, void *ptr)
Definition mem.c:49
void * agrealloc(Agraph_t *g, void *ptr, size_t oldsize, size_t size)
Definition mem.c:29
void agerrorf(const char *fmt,...)
Definition agerror.c:165
graph or subgraph
Definition cgraph.h:425