Mercurial > hg > toybox
comparison lib/lib.c @ 1030:9686469a857a draft
Rewrite pmap to be simpler and match other implementation's output more closely.
author | Rob Landley <rob@landley.net> |
---|---|
date | Tue, 27 Aug 2013 23:48:54 -0500 |
parents | 910f35ff76be |
children | cbc467592b2e |
comparison
equal
deleted
inserted
replaced
1029:b59f4b87b9ec | 1030:9686469a857a |
---|---|
323 char *buf; | 323 char *buf; |
324 | 324 |
325 fd = open(name, O_RDONLY); | 325 fd = open(name, O_RDONLY); |
326 if (fd == -1) return 0; | 326 if (fd == -1) return 0; |
327 len = fdlength(fd); | 327 len = fdlength(fd); |
328 // proc files don't report a length, so try 1 page minimum. | |
329 if (len<4096) len = 4095; | |
328 buf = xmalloc(len+1); | 330 buf = xmalloc(len+1); |
329 buf[readall(fd, buf, len)] = 0; | 331 buf[readall(fd, buf, len)] = 0; |
330 | 332 |
331 return buf; | 333 return buf; |
332 } | 334 } |