This source file includes following definitions.
- ADIOI_Malloc_request
- ADIOI_Free_request
1
2
3
4
5
6
7
8 #include "adio.h"
9 #include "adio_extern.h"
10
11 struct ADIOI_RequestD *ADIOI_Malloc_request(void)
12 {
13
14
15
16
17
18
19 #define NUM 100
20
21 ADIOI_Req_node *curr, *ptr;
22 int i;
23
24 if (!ADIOI_Req_avail_head) {
25 ADIOI_Req_avail_head = (ADIOI_Req_node *)
26 ADIOI_Malloc(NUM*sizeof(ADIOI_Req_node));
27 if (ADIOI_Req_avail_head == NULL)
28 {
29
30 return NULL;
31 }
32 curr = ADIOI_Req_avail_head;
33 for (i=1; i<NUM; i++) {
34 curr->next = ADIOI_Req_avail_head+i;
35 curr = curr->next;
36 }
37 curr->next = NULL;
38 ADIOI_Req_avail_tail = curr;
39
40
41 if (!ADIOI_Malloc_req_tail) {
42 ADIOI_Malloc_req_tail = (ADIOI_Malloc_req *)
43 ADIOI_Malloc(sizeof(ADIOI_Malloc_req));
44 ADIOI_Malloc_req_head = ADIOI_Malloc_req_tail;
45 ADIOI_Malloc_req_head->ptr = ADIOI_Req_avail_head;
46 ADIOI_Malloc_req_head->next = NULL;
47 }
48 else {
49 ADIOI_Malloc_req_tail->next = (ADIOI_Malloc_req *)
50 ADIOI_Malloc(sizeof(ADIOI_Malloc_req));
51 ADIOI_Malloc_req_tail = ADIOI_Malloc_req_tail->next;
52 ADIOI_Malloc_req_tail->ptr = ADIOI_Req_avail_head;
53 ADIOI_Malloc_req_tail->next = NULL;
54 }
55 }
56
57 ptr = ADIOI_Req_avail_head;
58 ADIOI_Req_avail_head = ADIOI_Req_avail_head->next;
59 if (!ADIOI_Req_avail_head) ADIOI_Req_avail_tail = NULL;
60
61 (ptr->reqd).cookie = ADIOI_REQ_COOKIE;
62 return &(ptr->reqd);
63 }
64
65
66 void ADIOI_Free_request(ADIOI_Req_node *node)
67 {
68
69
70
71
72
73 (node->reqd).cookie = 0;
74
75 if (!ADIOI_Req_avail_tail)
76 ADIOI_Req_avail_head = ADIOI_Req_avail_tail = node;
77 else {
78 ADIOI_Req_avail_tail->next = node;
79 ADIOI_Req_avail_tail = node;
80 }
81 node->next = NULL;
82 }
83