FrontISTR  5.7.0
Large-scale structural analysis program with finit element method
hecmw_vis_mem_util.c
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright (c) 2019 FrontISTR Commons
3  * This software is released under the MIT License, see LICENSE.txt
4  *****************************************************************************/
5 
6 #include "hecmw_vis_mem_util.h"
7 
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include "hecmw_util.h"
11 
12 void HECMW_vis_memory_exit(char *var) {
13  fprintf(stderr,
14  "#### HEC-MW-VIS-E0001:There is no enough memory allocated for "
15  "variable %s\n",
16  var);
18  exit(0);
19 }
20 
21 void HECMW_vis_print_exit(char *var) {
22  fprintf(stderr, "%s\n", var);
24  exit(0);
25 }
26 
27 void mfree(void *pointer) {
28  HECMW_free(pointer);
29  pointer = NULL;
30 }
31 
32 Point *alloc_verts(int num) {
33  int i;
34  Point *verts;
35 
36  if ((verts = (Point *)HECMW_calloc(num, sizeof(Point))) == NULL) {
37  fprintf(stderr, "There is not enough memory, alloc_verts\n");
38  return NULL;
39  }
40 
41  for (i = 0; i < (num - 1); i++) {
42  (verts + i)->nextpoint = (verts + i + 1);
43  (verts + i)->ident = 0;
44  }
45  (verts + num - 1)->ident = 0;
46  (verts + num - 1)->nextpoint = NULL;
47 
48  return verts;
49 }
50 
52  int i;
53  Polygon *polygons;
54 
55  if ((polygons = (Polygon *)HECMW_calloc(num, sizeof(Polygon))) == NULL) {
56  fprintf(stderr, "There is not enough memory, alloc_polygons\n");
57  return NULL;
58  }
59 
60  for (i = 0; i < (num - 1); i++) {
61  (polygons + i)->nextpolygon = (polygons + i + 1);
62  (polygons + i)->plist = NULL;
63  }
64  (polygons + num - 1)->nextpolygon = NULL;
65  (polygons + num - 1)->plist = NULL;
66 
67  return polygons;
68 }
hecmw_vis_mem_util.h
HECMW_vis_print_exit
void HECMW_vis_print_exit(char *var)
Definition: hecmw_vis_mem_util.c:21
HECMW_finalize
int HECMW_finalize(void)
Definition: hecmw_finalize.c:9
HECMW_calloc
#define HECMW_calloc(nmemb, size)
Definition: hecmw_malloc.h:21
HECMW_vis_memory_exit
void HECMW_vis_memory_exit(char *var)
Definition: hecmw_vis_mem_util.c:12
_polygon_struct
Definition: hecmw_vis_SF_geom.h:209
mfree
void mfree(void *pointer)
Definition: hecmw_vis_mem_util.c:27
_point_struct
Definition: hecmw_vis_SF_geom.h:197
alloc_verts
Point * alloc_verts(int num)
Definition: hecmw_vis_mem_util.c:32
NULL
#define NULL
Definition: hecmw_io_nastran.c:30
HECMW_free
#define HECMW_free(ptr)
Definition: hecmw_malloc.h:24
alloc_polygons
Polygon * alloc_polygons(int num)
Definition: hecmw_vis_mem_util.c:51
hecmw_util.h