SCALAPACK 2.2.2
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ PB_Cgetbuf()

char * PB_Cgetbuf ( char *  MESS,
Int  LENGTH 
)

Definition at line 22 of file PB_Cgetbuf.c.

32{
33/*
34* Purpose
35* =======
36*
37* PB_Cgetbuf allocates a dynamic memory buffer. The routine checks the
38* size of the already allocated buffer against the value of the formal
39* parameter LENGTH. If the current buffer is large enough, this a poin-
40* ter to it is returned. Otherwise, this function tries to allocate it.
41* In case of failure, the program is stopped by calling Cblacs_abort.
42* When LENGTH is zero, this function returns a NULL pointer. If the va-
43* lue of LENGTH is strictly less than zero, the buffer is released.
44*
45* Arguments
46* =========
47*
48* MESS (local input) pointer to CHAR
49* On entry, MESS is a string containing a message to be printed
50* in case of allocation failure.
51*
52* LENGTH (local input) INTEGER
53* On entry, LENGTH specifies the length in bytes of the buffer
54* to be allocated. If LENGTH is less or equal than zero, this
55* function returns NULL.
56*
57* -- Written on April 1, 1998 by
58* Antoine Petitet, University of Tennessee, Knoxville 37996, USA.
59*
60* ---------------------------------------------------------------------
61*/
62/*
63* .. Local Scalars ..
64*/
65 static char * pblasbuf = NULL;
66 static Int pbbuflen = 0;
67/* ..
68* .. Executable Statements ..
69*
70*/
71 if( LENGTH >= 0 )
72 {
73 if( LENGTH > pbbuflen )
74 {
75 if( pblasbuf ) free( pblasbuf );
76 pblasbuf = (char *) malloc( (unsigned) LENGTH );
77 if( !pblasbuf )
78 {
79 (void) fprintf( stderr, "ERROR: Memory allocation failed\n%s\n",
80 MESS );
81 Cblacs_abort( -1, -1 );
82 }
83 pbbuflen = LENGTH;
84 }
85 }
86 else if( pblasbuf )
87 {
88 free( pblasbuf );
89 pblasbuf = NULL;
90 pbbuflen = 0;
91 }
92 return( pblasbuf );
93/*
94* End of PB_Cgetbuf
95*/
96}
#define Int
Definition Bconfig.h:22
void Cblacs_abort()
Here is the call graph for this function: