Changeset 5261
- Timestamp:
- May 1, 2008, 3:02:09 PM (17 years ago)
- Location:
- anuga_work/development/anugavis/src
- Files:
-
- 5 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_work/development/anugavis/src/Makefile.am
r5260 r5261 12 12 height_quantity.h \ 13 13 init.c \ 14 init.h 14 init.h \ 15 xmalloc.c \ 16 xmalloc.h 15 17 libanugavis_a_CFLAGS = @SDL_CFLAGS@ @GLU_CFLAGS@ 16 18 libanugavis_a_LIBADD = @LIBOBJS@ -
anuga_work/development/anugavis/src/globals.h
r5259 r5261 9 9 int netcdfId; 10 10 size_t number_of_points; 11 float *x; 12 float *y; 13 float *cells; 11 14 struct height_quantity_simple *heights; 12 15 } ANUGAVIS; -
anuga_work/development/anugavis/src/height_quantity.c
r5260 r5261 14 14 #include "globals.h" 15 15 #include "height_quantity.h" 16 #include "xmalloc.h" 16 17 17 18 int AnugaVis_DefineHeightQuantity(const char *name, … … 33 34 34 35 if(height == NULL){ /* Make a new entry. */ 35 if((height = malloc(sizeof(struct height_quantity_simple))) == NULL){ 36 AnugaVis_SetError("Failed to malloc %d bytes in " 37 "AnugaVis_DefineHeightQuantity()", 38 sizeof(struct height_quantity_simple)); 36 if((height = xmalloc(sizeof(struct height_quantity_simple), 37 "AnugaVis_DefineHeightQuantity()")) == NULL) 39 38 return -1; 40 }41 39 height->next = anugavis.heights; 42 40 anugavis.heights = height; -
anuga_work/development/anugavis/src/init.c
r5260 r5261 3 3 #endif 4 4 5 #ifdef HAVE_STDLIB_H 6 # include <stdlib.h> 7 #endif 5 8 #ifdef HAVE_GL_GL_H 6 9 # include <GL/gl.h> … … 17 20 #include "error.h" 18 21 #include "globals.h" 22 #include "xmalloc.h" 19 23 20 24 int AnugaVis_Init(int width, int height, const char *swwFilePath){ 21 25 int ncstatus; 22 26 int ncdimid; 27 int ncvarid; 28 anugavis.x = NULL; 29 anugavis.y = NULL; 30 anugavis.cells = NULL; 31 anugavis.heights = NULL; 23 32 if((SDL_Init(SDL_INIT_VIDEO) == -1) || 24 33 (SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5) == -1) || … … 44 53 &anugavis.netcdfId)) != NC_NOERR) goto nc_err; 45 54 if((ncstatus = nc_inq_dimid(anugavis.netcdfId, "number_of_points", 46 &ncdimid)) != NC_NOERR) goto nc_err ;55 &ncdimid)) != NC_NOERR) goto nc_err1; 47 56 if((ncstatus = nc_inq_dimlen(anugavis.netcdfId, ncdimid, 48 57 &anugavis.number_of_points)) != NC_NOERR) 49 goto nc_err ;58 goto nc_err1; 50 59 51 anugavis.heights = NULL; 60 /* Get the number of vertices to keep space for. */ 61 if((anugavis.x = xmalloc(sizeof(float) * anugavis.number_of_points, 62 "AnugaVis_Init()")) == NULL) 63 goto bad_malloc; 64 if((anugavis.y = xmalloc(sizeof(float) * anugavis.number_of_points, 65 "AnugaVis_Init()")) == NULL) 66 goto bad_malloc; 67 68 /* Load the list of x and y points from the NetCDF file. */ 69 if((ncstatus = nc_inq_varid(anugavis.netcdfId, "x", 70 &ncvarid)) != NC_NOERR) goto nc_err1; 71 if((ncstatus = nc_get_var_float(anugavis.netcdfId, ncvarid, 72 anugavis.x)) != NC_NOERR) goto nc_err1; 73 if((ncstatus = nc_inq_varid(anugavis.netcdfId, "y", 74 &ncvarid)) != NC_NOERR) goto nc_err1; 75 if((ncstatus = nc_get_var_float(anugavis.netcdfId, ncvarid, 76 anugavis.y)) != NC_NOERR) goto nc_err1; 77 52 78 return 0; 79 nc_err1: 80 nc_close(anugavis.netcdfId); 53 81 nc_err: 54 82 AnugaVis_NetCDFError(ncstatus); 83 bad_malloc: 84 if(anugavis.x != NULL) free(anugavis.x); 85 if(anugavis.y != NULL) free(anugavis.y); 55 86 SDL_Quit(); 56 87 return -1; … … 61 92 AnugaVis_UndefineHeightQuantity(anugavis.heights->name); 62 93 nc_close(anugavis.netcdfId); 94 free(anugavis.x); 95 free(anugavis.y); 63 96 SDL_Quit(); 64 97 }
Note: See TracChangeset
for help on using the changeset viewer.