将int-C的空值*转换为2D数组
\*assume that i have a data structure called graph with some *element "void** graph" in it and some element "int order" */void initialise_graph_data(graph_t *graph){ void **graph_data = NULL; int (*matrix)[graph->order]; size_t size = (graph->order * graph->order) * sizeof(int); graph_data = safe_malloc(size); /*safe malloc works fine*/ matrix = (int(*)[graph->order])graph_data; graph->graph = graph_data;}
graph->graph = (int(*)[graph->order])graph_data;
函数式编程
相关分类