/[smeserver]/rpms/cpu/sme7/cpu-1.4.3-read.patch
ViewVC logotype

Annotation of /rpms/cpu/sme7/cpu-1.4.3-read.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (hide annotations) (download)
Mon Mar 31 17:40:55 2008 UTC (16 years, 8 months ago) by slords
Branch: MAIN
CVS Tags: cpu-1_4_3-5_el4_sme, HEAD
Import on branch sme7 of package cpu-1.4.3-5.el4.sme.src.rpm

1 slords 1.1 diff -Nur -x '*.orig' -x '*.rej' cpu-1.4.3/src/util/parser.c mezzanine_patched_cpu-1.4.3/src/util/parser.c
2     --- cpu-1.4.3/src/util/parser.c 2003-10-22 17:17:15.000000000 -0400
3     +++ mezzanine_patched_cpu-1.4.3/src/util/parser.c 2007-07-24 15:17:47.000000000 -0400
4     @@ -57,6 +57,8 @@
5     {
6     int fd = 0;
7     ssize_t retval = 0;
8     + ssize_t nread;
9     + ssize_t bufsize;
10     void * temp;
11     struct stat buf;
12    
13     @@ -75,14 +77,31 @@
14     return NULL;
15     }
16    
17     - temp = malloc(buf.st_size);
18     - if ( temp == NULL )
19     - return NULL;
20     - bzero(temp, buf.st_size);
21     -
22     - retval = read(fd, temp, buf.st_size);
23     + for (nread = 0, temp = NULL, bufsize = 4096; ;bufsize *= 2)
24     + {
25     + void *temp2;
26     + ssize_t rbufsize;
27     + temp2 = malloc(bufsize);
28     + if ( temp2 == NULL )
29     + {
30     + perror(filename);
31     + return NULL;
32     + }
33     + bzero(temp2, bufsize);
34     + if (temp)
35     + {
36     + memcpy(temp2, temp, nread);
37     + free(temp);
38     + }
39     + temp = temp2;
40     + rbufsize = bufsize - nread;
41     + retval = read(fd, temp+nread, rbufsize);
42     + nread += retval;
43     + if (retval < rbufsize)
44     + break;
45     + }
46     close(fd);
47     - if ( retval != buf.st_size )
48     + if (buf.st_size && nread != buf.st_size )
49     printf("Hmm, didn't read all wanted data. Continuing\n");
50     if ( retval < 0 )
51     return NULL;

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed