Graphviz 13.0.0~dev.20241220.2304
Loading...
Searching...
No Matches
alloc.h File Reference

Memory allocation wrappers that exit on failure. More...

#include <assert.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <util/exit.h>
#include <util/prisize_t.h>
Include dependency graph for alloc.h:

Go to the source code of this file.

Functions

static void * gv_calloc (size_t nmemb, size_t size)
 
static void * gv_alloc (size_t size)
 
static void * gv_realloc (void *ptr, size_t old_size, size_t new_size)
 
static void * gv_recalloc (void *ptr, size_t old_nmemb, size_t new_nmemb, size_t size)
 
static char * gv_strdup (const char *original)
 
static char * gv_strndup (const char *original, size_t length)
 

Detailed Description

Much Graphviz code is not in a position to gracefully handle failure of dynamic memory allocation. The following wrappers provide a safe compromise where allocation failure does not need to be handled, but simply causes process exit. This is not ideal for external callers, but it is better than memory corruption or confusing crashes.

Note that the wrappers also take a more comprehensive strategy of zeroing newly allocated memory than malloc. This reduces the number of things callers need to think about and has only a modest overhead.

Definition in file alloc.h.

Function Documentation

◆ gv_alloc()

static void * gv_alloc ( size_t  size)
inlinestatic

Definition at line 47 of file alloc.h.

References gv_calloc().

Referenced by addChan(), addid(), addRow(), addRow(), addTri(), aginternalmapinsert(), agnewsym(), agpushdisc(), appendFLineList(), appendFLineList(), appendSeg(), attr_list_new(), base64_encode(), circomps(), class2(), cloneGraph(), concat(), concat(), create_hierarchy(), createSGraph(), deriveGraph(), dfs(), epsf_init(), extract_adjacency(), extractHChans(), extractVChans(), fdp_init_graph(), fillMap(), find_all_cycles(), find_ints(), find_ints(), find_me(), find_share(), find_tight_subtree(), findCComp(), genEllipticPath(), getfree(), glCompButtonNew(), glCompImageNew(), glCompLabelNew(), glCompPanelNew(), glCompSetAddNewTexture(), glCompSetNew(), graph_init(), graphviz_tred(), gv_strndup(), gvCloneGVC(), gvconfig(), gvg_init(), gvjobs_output_filename(), gvjobs_output_langname(), gvNEWcontext(), gvplugin_install(), gvplugin_library_load(), gvusershape_open(), idopen(), init_job_viewport(), init_viewport(), initFocus(), initGrid(), initSubg(), insert(), installnode(), localsubg(), main(), make_aux_edge(), make_graph(), make_label(), make_nitem(), makeClustObs(), makeDerivedNode(), makeObstacle(), makeTreeGen(), makeXDotSpline(), map_output_bspline(), mkAttr(), mkBlock(), mkClusters(), mkDeriveNode(), mkEdge(), mkItem(), mkLabel(), mkMaze(), mkMPair(), mkNode(), mkPair(), mkPoly(), mkRouter(), mkText(), mkText(), mkTree(), mkTree(), mkTreeNode(), mkTriGraph(), Multilevel_init(), Multilevel_Modularity_Clustering_init(), Multilevel_MQ_Clustering_init(), myiddisc_open(), new_attr(), new_attr_ref(), new_matrix(), new_spline(), new_viewport_camera(), new_virtual_edge(), newBlock(), newedge(), newIpair(), newitem(), newitem(), newItem(), newItem(), newitem(), newnode(), node_data_new(), node_set_new(), parse_reclbl(), parseXDotFOn(), point_init(), poly_init(), PQinitialize(), push(), push(), push(), push_obj_state(), pushAlist(), pushG(), QuadTree_new(), RTreeNewNode(), SparseMatrix_init(), SparseStressMajorizationSmoother_new(), spring_electrical_control_new(), SpringSmoother_new(), STbuildheap(), StressMajorizationSmoother2_new(), textfont_makef(), TriangleSmoother_new(), user_init(), user_shape(), virtual_node(), xdot_begin_graph(), xdotBB(), xlhdxload(), and xlnew().

Here is the call graph for this function:

◆ gv_calloc()

static void * gv_calloc ( size_t  nmemb,
size_t  size 
)
inlinestatic

Definition at line 26 of file alloc.h.

References graphviz_exit(), NULL, PRISIZE_T, and SIZE_MAX.

Referenced by abomination(), addBindings(), addXLabels(), adjustGrid(), agbindrec(), agclos(), agmakeattrs(), agopen(), agstrdup_internal(), agxbmore(), alloc_interpolation_points(), allocArray(), allocate_ranks(), allocpoly(), appendFLineList(), appendFLineList(), arrayRects(), attach_edge_label_coordinates(), attached_clustering(), attachOrthoEdges(), attachPos(), bitarray_new(), build_skeleton(), cAdjust(), call_tri(), call_tri2(), cg(), circuitModel(), circular_init_node_edge(), cloneClusterTree(), cloneGraph(), cloneGraph(), coarsen_match(), color(), color_blend_rgb2lab(), combineCallback(), compileProg(), compute_apsp_artificial_weights_packed(), compute_apsp_dijkstra(), compute_apsp_packed(), compute_apsp_simple(), compute_densities(), compute_new_weights(), compute_weighted_apsp_packed(), computeScaleXY(), conjugate_gradient(), conjugate_gradient(), conjugate_gradient_f(), conjugate_gradient_mkernel(), construct_graph(), construct_trapezoids(), convertSPtoRoute(), copyCluster(), copyClusterInfo(), copyPts(), cpExGraph(), cpGraph(), create_color_theme(), create_hierarchy(), createSGraph(), deriveGraph(), diag_precon_new(), dijkstra(), dijkstra_f(), dijkstra_sgd(), dot_splines_(), dotneato_args_initialize(), ELinitialize(), embed_graph(), emit_begin_node(), emit_edge_graphics(), emit_map_rect(), emit_page(), expandCluster(), extract_adjacency(), fdp_init_node_edge(), feasible_tree(), fillRanks(), find_closest_pairs(), find_ints(), find_ints(), find_pair_edges(), findCComp(), fixLabelOrder(), furtherest_point(), furtherest_point_in_list(), genCnt(), genPoly(), genRound(), genroute(), get_edge_label_matrix(), get_font_mapping(), get_mq(), get_or_alloc_force_qt(), get_poly_lines(), get_polygon_solids(), get_polygons(), get_tri(), getEdgeList(), getfree(), getPos(), getRankseps(), getSizes(), glCompSetAddNewTexture(), gv_alloc(), gvrender_beziercurve(), gvrender_polygon(), gvrender_polyline(), hierachical_modularity_clustering(), hierachical_mq_clustering(), ideal_distance_matrix(), Import_coord_clusters_from_dot(), Import_dot_splines(), init(), init_ex_graph(), init_graph(), init_mincross(), init_node(), initFocus(), initHeap(), initHeap(), initHeap_f(), initSEdges(), inPoly(), interpolate_coord(), lab_gamut(), layout(), layout(), layoutTree(), linGradient(), lu_decompose(), majorization(), make_barriers(), make_barriers(), make_coarse_ex_graph(), make_coarse_graph(), make_graph(), make_leafslots(), make_map_from_rectangle_groups(), make_map_internal(), makeAddPoly(), makeClustObs(), makeCompoundEdge(), makeDerivedNode(), makeDotGraph(), makeGraph(), makeGraphData(), makeInfo(), makeMatrix(), makeMultiSpline(), makeObstacle(), makePath(), makePoly(), makeSelfArcs(), makeSierpinski(), makeSimpleFlatLabels(), makeStraightEdge(), makeTetrix(), makeXDotSpline(), map_label(), map_palette_optimal_coloring(), map_point(), matinv(), maximal_independent_edge_set_heavest_edge_pernode_supernodes_first(), maxmatch(), mkCtrlPts(), mkDeriveNode(), mkDirlist(), mkMaze(), mkMazeGraph(), mkPoly(), mkQueue(), mkRouter(), mkStmts(), mkText(), mkText(), mkTree(), mkTriGraph(), mkTriIndices(), monotonate_trapezoids(), move_node(), mult_dense_mat(), mult_dense_mat_d(), mult_sparse_dense_mat_transpose(), Multilevel_coarsen_internal(), Multilevel_Modularity_Clustering_establish(), Multilevel_Modularity_Clustering_init(), Multilevel_MQ_Clustering_establish(), Multilevel_MQ_Clustering_init(), multilevel_spring_electrical_embedding(), neato_init_node(), neato_layout(), new_3array(), new_array(), new_matrix(), new_spline(), newBlock(), node_data_new(), node_distinct_coloring(), node_distinct_coloring_internal2(), node_set_add(), orthoEdges(), parse_layerselect(), parse_reclbl(), parsePolyline(), parseXDotFOn(), partition(), patchwork_init_node_edge(), PCA_alloc(), pEllipse(), Plegal_arrangement(), Plegal_arrangement(), Pobspath(), point_init(), pointsOf(), poly_gencode(), poly_init(), polyGraphs(), polyOverlap(), polyRects(), position(), positionAllItems(), power_iteration(), power_law_graph(), power_method(), Ppolybarriers(), PQgen(), PQinitialize(), prepare_topological_fisheye(), printSorted(), processTbl(), Ptriangulate(), ptVis(), putGraphs(), QuadTree_add_internal(), QuadTree_get_supernodes(), QuadTree_new(), QuadTree_new_from_point_list(), radGradient(), random_permutation(), readout_levels(), record_init(), Render_Contour2(), renderresult(), rescale_layout_polar(), rescale_layout_polarFocus(), round_corners(), rounded_draw(), routesplines_(), scAdjust(), scan_graph_mode(), set_active_levels(), set_cell_heights(), set_cell_widths(), sgd(), shortest_path(), shortestPath(), shorting_edge_label_nodes(), simpleSplineRoute(), smooth_vec(), smyrnaPath(), solve(), sortSites(), sparse_stress_subspace_majorization_kD(), SparseMatrix_add(), SparseMatrix_alloc(), SparseMatrix_decompose_to_supervariables(), SparseMatrix_distance_matrix(), SparseMatrix_get_augmented(), SparseMatrix_get_real_adjacency_matrix_symmetrized(), SparseMatrix_get_submatrix(), SparseMatrix_import_dot(), SparseMatrix_import_matrix_market(), SparseMatrix_init(), SparseMatrix_is_symmetric(), SparseMatrix_level_sets(), SparseMatrix_multiply_vector(), SparseMatrix_realloc(), SparseMatrix_set_entries_to_real_one(), SparseMatrix_sum_repeat_entries(), SparseMatrix_weakly_connected_components(), SparseStressMajorizationSmoother_new(), spline_edges_(), splines_intersect(), splitBSpline(), spring_electrical_embedding(), spring_electrical_embedding_fast(), spring_electrical_embedding_slow(), spring_electrical_spring_embedding(), SpringSmoother_new(), stress_majorization_kD_mkernel(), stress_model(), StressMajorizationSmoother2_new(), TB_balance(), tcldot_argv_dup(), tree_map(), TriangleSmoother_new(), triPath(), twopi_init_node_edge(), UG_graph(), undoClusterEdges(), update_tree(), user_init(), user_spline(), vc_refresh(), vector_float_take(), vector_ordering(), and write_edges().

Here is the call graph for this function:

◆ gv_realloc()

static void * gv_realloc ( void *  ptr,
size_t  old_size,
size_t  new_size 
)
inlinestatic

Definition at line 49 of file alloc.h.

References free(), graphviz_exit(), NULL, and PRISIZE_T.

Referenced by addstr(), addstr(), agopen1(), find_me(), gv_recalloc(), readln(), storeFileName(), and storeFileName().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gv_recalloc()

static void * gv_recalloc ( void *  ptr,
size_t  old_nmemb,
size_t  new_nmemb,
size_t  size 
)
inlinestatic

◆ gv_strdup()

static char * gv_strdup ( const char *  original)
inlinestatic

◆ gv_strndup()

static char * gv_strndup ( const char *  original,
size_t  length 
)
inlinestatic

Definition at line 114 of file alloc.h.

References copy(), graphviz_exit(), gv_alloc(), NULL, PRISIZE_T, and SIZE_MAX.

Referenced by agxbdisown(), split(), and strview_str().

Here is the call graph for this function:
Here is the caller graph for this function: