00001
00002
00003
00004
00005
00006
00007
00008 #include "adio.h"
00009 #include "adio_extern.h"
00010
00011 struct ADIOI_RequestD *ADIOI_Malloc_request(void)
00012 {
00013
00014
00015
00016
00017
00018
00019 #define NUM 100
00020
00021 ADIOI_Req_node *curr, *ptr;
00022 int i;
00023
00024 if (!ADIOI_Req_avail_head) {
00025 ADIOI_Req_avail_head = (ADIOI_Req_node *)
00026 ADIOI_Malloc(NUM*sizeof(ADIOI_Req_node));
00027 if (ADIOI_Req_avail_head == NULL)
00028 {
00029
00030 return NULL;
00031 }
00032 curr = ADIOI_Req_avail_head;
00033 for (i=1; i<NUM; i++) {
00034 curr->next = ADIOI_Req_avail_head+i;
00035 curr = curr->next;
00036 }
00037 curr->next = NULL;
00038 ADIOI_Req_avail_tail = curr;
00039
00040
00041 if (!ADIOI_Malloc_req_tail) {
00042 ADIOI_Malloc_req_tail = (ADIOI_Malloc_req *)
00043 ADIOI_Malloc(sizeof(ADIOI_Malloc_req));
00044 ADIOI_Malloc_req_head = ADIOI_Malloc_req_tail;
00045 ADIOI_Malloc_req_head->ptr = ADIOI_Req_avail_head;
00046 ADIOI_Malloc_req_head->next = NULL;
00047 }
00048 else {
00049 ADIOI_Malloc_req_tail->next = (ADIOI_Malloc_req *)
00050 ADIOI_Malloc(sizeof(ADIOI_Malloc_req));
00051 ADIOI_Malloc_req_tail = ADIOI_Malloc_req_tail->next;
00052 ADIOI_Malloc_req_tail->ptr = ADIOI_Req_avail_head;
00053 ADIOI_Malloc_req_tail->next = NULL;
00054 }
00055 }
00056
00057 ptr = ADIOI_Req_avail_head;
00058 ADIOI_Req_avail_head = ADIOI_Req_avail_head->next;
00059 if (!ADIOI_Req_avail_head) ADIOI_Req_avail_tail = NULL;
00060
00061 (ptr->reqd).cookie = ADIOI_REQ_COOKIE;
00062 return &(ptr->reqd);
00063 }
00064
00065
00066 void ADIOI_Free_request(ADIOI_Req_node *node)
00067 {
00068
00069
00070
00071
00072
00073 (node->reqd).cookie = 0;
00074
00075 if (!CtvAccess(ADIOI_Req_avail_tail))
00076 CtvAccess(ADIOI_Req_avail_head) = CtvAccess(ADIOI_Req_avail_tail) = node;
00077 else {
00078 CtvAccess(ADIOI_Req_avail_tail)->next = node;
00079 CtvAccess(ADIOI_Req_avail_tail) = node;
00080 }
00081 node->next = NULL;
00082 }
00083