Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /sml/trunk/src/runtime/c-libs/posix-io/read.c
ViewVC logotype

Diff of /sml/trunk/src/runtime/c-libs/posix-io/read.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 8, Sun Jan 18 01:01:29 1998 UTC revision 223, Sat Apr 17 16:27:01 1999 UTC
# Line 21  Line 21 
21  {  {
22      int             fd = REC_SELINT(arg, 0);      int             fd = REC_SELINT(arg, 0);
23      int             nbytes = REC_SELINT(arg, 1);      int             nbytes = REC_SELINT(arg, 1);
24      ml_val_t        vec;      ml_val_t        vec, res;
25      int             n;      int             n;
26    
27        if (nbytes == 0)
28            return ML_string0;
29    
30    /* allocate the vector; note that this might cause a GC */    /* allocate the vector; note that this might cause a GC */
31      vec = ML_AllocString (msp, nbytes);      vec = ML_AllocRaw32 (msp, BYTES_TO_WORDS(nbytes));
32      n = read (fd, PTR_MLtoC(char, vec), nbytes);      n = read (fd, PTR_MLtoC(char, vec), nbytes);
33      if (n < 0)      if (n < 0)
34          return RAISE_SYSERR(msp, n);          return RAISE_SYSERR(msp, n);
35        else if (n == 0)
36            return ML_string0;
37    
38      if (n < nbytes) {      if (n < nbytes) {
39        /* we need to correct the length in the descriptor */        /* we need to shrink the vector */
40          PTR_MLtoC(ml_val_t, vec)[-1] = MAKE_DESC(n, DTAG_string);          ML_ShrinkRaw32 (msp, vec, BYTES_TO_WORDS(n));
41      }      }
42    
43      return vec;      SEQHDR_ALLOC (msp, res, DESC_string, vec, n);
44    
45        return res;
46    
47  } /* end of _ml_P_IO_read */  } /* end of _ml_P_IO_read */

Legend:
Removed from v.8  
changed lines
  Added in v.223

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0