OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
BI_GetBuff.c File Reference
#include "Bdef.h"

Go to the source code of this file.

Functions

BLACBUFFBI_GetBuff (Int length)

Function Documentation

◆ BI_GetBuff()

BLACBUFF * BI_GetBuff ( Int length)

Definition at line 37 of file BI_GetBuff.c.

38{
39 void BI_EmergencyBuff(Int length);
40
41 char *cptr;
42 Int i, j;
43 extern Int BI_Np;
44 extern BLACBUFF *BI_ReadyB;
45
46/*
47 * If ready buffer already exists, and is big enough, return it. Otherwise,
48 * free the buffer (if it exists) and get one of correct size
49 */
50 if (BI_ReadyB)
51 {
52 if (BI_ReadyB->Len >= length) return(BI_ReadyB);
53 else free(BI_ReadyB);
54 }
55/*
56 * Make sure all buffers aligned correctly
57 */
58 j = sizeof(BLACBUFF);
59 if (j % sizeof(MPI_Request))
60 j += sizeof(MPI_Request) - j % sizeof(MPI_Request);
61 i = j + BI_Np*sizeof(MPI_Request);
62 if (i % BUFFALIGN) i += BUFFALIGN - i % BUFFALIGN;
63 cptr = malloc(i + length);
64 BI_ReadyB = (BLACBUFF *) cptr;
65
66 if (BI_ReadyB != NULL)
67 {
68 BI_ReadyB->nAops = 0;
69 BI_ReadyB->Aops = (MPI_Request *) &cptr[j];
70 BI_ReadyB->Buff = &cptr[i];
71 BI_ReadyB->Len = length;
72 }
73 else BI_EmergencyBuff(length);
74
75 return(BI_ReadyB);
76}
void BI_EmergencyBuff(Int length)
BLACBUFF * BI_ReadyB
Int BI_Np
#define Int
Definition Bconfig.h:22
struct bLaCbUfF BLACBUFF
Definition Bdef.h:53
#define BUFFALIGN
Definition Bdef.h:75