OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
alloc_vcal.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include "vcal_struc.h"
5 #include "l12_parms.h"
6 
7 /* --------------------------------------------------------- */
8 /* alloc_target() - allocates 1 target record to hold data */
9 /* for a single scan of "npix" pixels. */
10 
11 /* --------------------------------------------------------- */
12 int alloc_vcal(int32_t npix, int32_t nbands, vcstr *rec) {
13  char *p;
14  int32_t len = sizeof (float)*npix * nbands * 6;
15 
16  if ((p = (char *) malloc(len)) == NULL) {
17  fprintf(stderr,
18  "-E- %s line %d: Memory allocation failure.\n",
19  __FILE__, __LINE__);
20  return (0);
21  }
22  memset(p, '\0', len);
23 
24  rec->length = len;
25  rec->npix = npix;
26  rec->nbands = nbands;
27  rec->data = p;
28 
29  rec->vLt = (float *) p;
30  p += sizeof (float)*npix*nbands;
31  rec->Lw = (float *) p;
32  p += sizeof (float)*npix*nbands;
33  rec->nLw = (float *) p;
34  p += sizeof (float)*npix*nbands;
35  rec->tLw = (float *) p;
36  p += sizeof (float)*npix*nbands;
37  rec->brdfsat = (float *) p;
38  p += sizeof (float)*npix*nbands;
39  rec->brdftgt = (float *) p;
40  p += sizeof (float)*npix*nbands;
41 
42  return (len);
43 }
#define NULL
Definition: decode_rs.h:63
int32_t nbands
int npix
Definition: get_cmp.c:27
float p[MODELMAX]
Definition: atrem_corl1.h:131
int alloc_vcal(int32_t npix, int32_t nbands, vcstr *rec)
Definition: alloc_vcal.c:12