FrontISTR  5.7.0
Large-scale structural analysis program with finit element method
hecmw_couple_weight.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 <stdio.h>
7 #include <stdlib.h>
8 #include <string.h>
9 #include <errno.h>
10 #include <assert.h>
11 
12 #include "hecmw_malloc.h"
13 #include "hecmw_couple_define.h"
14 #include "hecmw_couple_weight.h"
15 
17  struct hecmw_couple_weight *p = NULL;
18 
19  p = (struct hecmw_couple_weight *)HECMW_malloc(
20  sizeof(struct hecmw_couple_weight));
21  if (p == NULL) {
22  HECMW_set_error(errno, "");
23  return NULL;
24  }
25  p->n = 0;
27  p->index = NULL;
28  p->id = NULL;
29  p->weight = NULL;
30 
31  return p;
32 }
33 
35  if (p == NULL) return;
36 
37  HECMW_free(p->index);
38  HECMW_free(p->id);
39  HECMW_free(p->weight);
40 }
41 
42 /*------------------------------------------------------------------------------------------------*/
43 
45  struct hecmw_couple_weight_list *p;
46 
48  sizeof(struct hecmw_couple_weight_list));
49  if (p == NULL) {
50  HECMW_set_error(errno, "");
51  return NULL;
52  }
53  p->info = NULL;
54  p->next = NULL;
55 
56  return p;
57 }
58 
60  struct hecmw_couple_weight_list *p, *q;
61 
62  if (r == NULL) return;
63 
64  for (p = r; p; p = q) {
65  q = p->next;
67  HECMW_free(p);
68  }
69  r = NULL;
70 }
hecmw_malloc.h
hecmw_couple_weight
Definition: hecmw_couple_weight.h:9
hecmw_couple_weight_list::next
struct hecmw_couple_weight_list * next
Definition: hecmw_couple_weight.h:19
hecmw_couple_weight_list::info
struct hecmw_couple_weight * info
Definition: hecmw_couple_weight.h:18
hecmw_couple_weight.h
HECMW_malloc
#define HECMW_malloc(size)
Definition: hecmw_malloc.h:20
hecmw_couple_weight::n
int n
Definition: hecmw_couple_weight.h:13
HECMW_couple_free_weight
void HECMW_couple_free_weight(struct hecmw_couple_weight *p)
Definition: hecmw_couple_weight.c:34
HECMW_couple_free_weight_list
void HECMW_couple_free_weight_list(struct hecmw_couple_weight_list *r)
Definition: hecmw_couple_weight.c:59
hecmw_couple_weight::weight
double * weight
Definition: hecmw_couple_weight.h:17
HECMW_COUPLE_IP_UNDEF
#define HECMW_COUPLE_IP_UNDEF
Definition: hecmw_couple_define.h:41
hecmw_couple_weight_list
Definition: hecmw_couple_weight.h:17
hecmw_couple_weight::id
int * id
Definition: hecmw_couple_weight.h:16
hecmw_couple_weight::index
int * index
Definition: hecmw_couple_weight.h:15
hecmw_couple_weight::type
int type
Definition: hecmw_couple_weight.h:14
HECMW_couple_alloc_weight
struct hecmw_couple_weight * HECMW_couple_alloc_weight(void)
Definition: hecmw_couple_weight.c:16
HECMW_set_error
int HECMW_set_error(int errorno, const char *fmt,...)
Definition: hecmw_error.c:37
NULL
#define NULL
Definition: hecmw_io_nastran.c:30
HECMW_free
#define HECMW_free(ptr)
Definition: hecmw_malloc.h:24
HECMW_couple_alloc_weight_list
struct hecmw_couple_weight_list * HECMW_couple_alloc_weight_list(void)
Definition: hecmw_couple_weight.c:44
hecmw_couple_define.h