diff options
author | root <root> | 2008-05-11 19:19:05 +0000 |
---|---|---|
committer | root <root> | 2008-05-11 19:19:05 +0000 |
commit | 43f39ab64b4406552d75c6bdbf19ebd2b76c84df (patch) | |
tree | 3f143e1920e68c864166d1a6207762ffb359bed4 | |
parent | 8541f20ee7cb98f930d6b66e64b30a024610b87a (diff) |
allow dynamic allocation
-rw-r--r-- | eio.c | 21 |
1 files changed, 13 insertions, 8 deletions
@@ -770,15 +770,18 @@ static void scandir_ (eio_req *req, worker *self) /*****************************************************************************/ #define ALLOC(len) \ - X_LOCK (wrklock); \ - req->flags |= EIO_FLAG_PTR2_FREE; \ - X_UNLOCK (wrklock); \ - req->ptr2 = malloc (len); \ if (!req->ptr2) \ { \ - errno = ENOMEM; \ - req->result = -1; \ - break; \ + X_LOCK (wrklock); \ + req->flags |= EIO_FLAG_PTR2_FREE; \ + X_UNLOCK (wrklock); \ + req->ptr2 = malloc (len); \ + if (!req->ptr2) \ + { \ + errno = ENOMEM; \ + req->result = -1; \ + break; \ + } \ } X_THREAD_PROC (eio_proc) @@ -834,7 +837,8 @@ X_THREAD_PROC (eio_proc) if (!EIO_CANCELLED (req)) switch (req->type) { - case EIO_READ: req->result = req->offs >= 0 + case EIO_READ: ALLOC (req->size); + req->result = req->offs >= 0 ? pread (req->int1, req->ptr2, req->size, req->offs) : read (req->int1, req->ptr2, req->size); break; case EIO_WRITE: req->result = req->offs >= 0 @@ -868,6 +872,7 @@ X_THREAD_PROC (eio_proc) case EIO_LINK: req->result = link (req->ptr1, req->ptr2); break; case EIO_SYMLINK: req->result = symlink (req->ptr1, req->ptr2); break; case EIO_MKNOD: req->result = mknod (req->ptr1, (mode_t)req->int2, (dev_t)req->offs); break; + case EIO_READLINK: ALLOC (NAME_MAX); req->result = readlink (req->ptr1, req->ptr2, NAME_MAX); break; |