/* Copy a given WSC structure into another one. */ struct wcsprm * gal_wcs_copy(struct wcsprm *wcs) { struct wcsprm *out; /* If the input WCS is NULL, return a NULL WCS. */ if(wcs) { /* Allocate the output WCS structure. */ errno=0; out=malloc(sizeof *out); if(out==NULL) error(EXIT_FAILURE, errno, "%s: allocating %zu bytes for `out'", __func__, sizeof *out); /* Initialize the allocated WCS structure. The WCSLIB manual says "On the first invokation, and only the first invokation, wcsprm::flag must be set to -1 to initialize memory management"*/ out->flag=-1; wcsini(1, wcs->naxis, out); /* Copy the input WCS to the output WSC structure. */ wcscopy(1, wcs, out); } else out=NULL; /* Return the final output. */ return out; }
int wcsini_(const int *naxis, int *wcs) { return wcsini(1, *naxis, (struct wcsprm *)wcs); }