From 3464e646f7fdd92aeaafeee8112ddb1f82a9c04a Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Tue, 12 Nov 2013 15:27:42 +0100 Subject: [PATCH] Use fread() to read facet number --- xs/src/admesh/stl.h | 1 - xs/src/admesh/stlinit.c | 13 +------------ 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/xs/src/admesh/stl.h b/xs/src/admesh/stl.h index b6e2a0bae..332a5bf2f 100644 --- a/xs/src/admesh/stl.h +++ b/xs/src/admesh/stl.h @@ -180,5 +180,4 @@ extern void stl_allocate(stl_file *stl); static void stl_read(stl_file *stl, int first_facet, int first); static void stl_facet_stats(stl_file *stl, stl_facet facet, int first); extern void stl_reallocate(stl_file *stl); -static int stl_get_little_int(FILE *fp); extern void stl_get_size(stl_file *stl); diff --git a/xs/src/admesh/stlinit.c b/xs/src/admesh/stlinit.c index 633ff639e..1e8893039 100644 --- a/xs/src/admesh/stlinit.c +++ b/xs/src/admesh/stlinit.c @@ -41,17 +41,6 @@ stl_open(stl_file *stl, char *file) fclose(stl->fp); } -static int -stl_get_little_int(FILE *fp) -{ - int value; - value = fgetc(fp) & 0xFF; - value |= (fgetc(fp) & 0xFF) << 0x08; - value |= (fgetc(fp) & 0xFF) << 0x10; - value |= (fgetc(fp) & 0xFF) << 0x18; - return(value); -} - void stl_initialize(stl_file *stl) @@ -132,7 +121,7 @@ stl_count_facets(stl_file *stl, char *file) stl->stats.header[80] = '\0'; /* Read the int following the header. This should contain # of facets */ - header_num_facets = stl_get_little_int(stl->fp); + fread(&header_num_facets, sizeof(int), 1, stl->fp); if(num_facets != header_num_facets) { fprintf(stderr,