Graphviz 12.0.1~dev.20240715.2254
Loading...
Searching...
No Matches
alloc.h File Reference

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

#include <assert.h>
#include <cgraph/exit.h>
#include <cgraph/prisize_t.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.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 addBlock(), addCase(), addChan(), addid(), addRow(), addTri(), appendFItemList(), appendFLineList(), appendSeg(), attr_list_new(), base64_encode(), circomps(), class2(), cloneGraph(), concat(), concat(), create_color_theme(), 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(), glNewFont(), glNewFontFromParent(), 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(), main(), make_aux_edge(), make_graph(), make_label(), make_nitem(), makeClustObs(), makeDerivedNode(), makeObstacle(), makeTreeGen(), makeXDotSpline(), map_output_bspline(), mkAttr(), mkBlock(), mkClusters(), mkClusters(), mkDeriveNode(), mkEdge(), mkIntItem(), mkItem(), mkLabel(), mkMaze(), mkMPair(), mkNode(), mkPair(), mkPoly(), mkRouter(), mkText(), mkTree(), mkTree(), mkTreeNode(), mkTriGraph(), Multilevel_init(), Multilevel_Modularity_Clustering_init(), Multilevel_MQ_Clustering_init(), new_attr(), new_attr_ref(), new_matrix(), new_spline(), new_viewport_camera(), new_virtual_edge(), newBlock(), newIpair(), newitem(), newItem(), newItem(), node_data_new(), node_set_new(), parse_reclbl(), parseXDotFOn(), point_init(), poly_init(), push(), push_obj_state(), pushFont(), pushG(), QuadTree_new(), RTreeNewNode(), setCell(), SparseMatrix_init(), SparseStressMajorizationSmoother_new(), spring_electrical_control_new(), SpringSmoother_new(), STbuildheap(), StressMajorizationSmoother2_new(), TriangleSmoother_new(), user_init(), user_shape(), vgpane(), 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 _spline_edges(), abomination(), addBindings(), addXLabels(), adjustGrid(), agclos(), agopen(), agxbmore(), alloc_interpolation_points(), allocArray(), allocate_ranks(), allocpoly(), appendFLineList(), arrayRects(), attach_edge_label_coordinates(), attached_clustering(), attachOrthoEdges(), attachPos(), bitarray_new(), build_skeleton(), cAdjust(), call_tri(), call_tri2(), cccomps(), ccomps(), cg(), circuitModel(), circular_init_node_edge(), cloneClusterTree(), 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(), findStopColor(), 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(), 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(), 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(), parseSegs(), parseXDotFOn(), partition(), patchwork_init_node_edge(), PCA_alloc(), pccomps(), 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(), queue_new(), radGradient(), random_permutation(), readout_levels(), record_init(), Render_Contour2(), rescale_layout_polar(), rescale_layout_polarFocus(), round_corners(), rounded_draw(), routesplines_(), scAdjust(), scan_graph_mode(), scanArgs(), set_active_levels(), sgd(), shortest_path(), shortestPath(), shorting_edge_label_nodes(), simpleSplineRoute(), sizeArray(), sizeLinearArray(), 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(), 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(), 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(), 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: