Mercurial > hg > octave-kai > gnulib-hg
annotate lib/safe-read.h @ 11639:b2e769838448
hash: fix memory leak in last patch
* lib/hash.c (hash_rehash): Avoid memory leak.
Signed-off-by: Eric Blake <ebb9@byu.net>
author | Eric Blake <ebb9@byu.net> |
---|---|
date | Thu, 18 Jun 2009 15:24:38 -0600 |
parents | bbbbbf4cd1c5 |
children | b5e42ef33b49 |
rev | line source |
---|---|
4002
9fcf64c770ed
Orthogonal approach to read()/write() that handles EINTR and counts > 2^31
Bruno Haible <bruno@clisp.org>
parents:
1431
diff
changeset
|
1 /* An interface to read() that retries after interrupts. |
7746
577c75e46325
* lib/safe-read.h [C++]: Wrap declarations in extern "C".
Jim Meyering <jim@meyering.net>
parents:
5848
diff
changeset
|
2 Copyright (C) 2002, 2006 Free Software Foundation, Inc. |
4002
9fcf64c770ed
Orthogonal approach to read()/write() that handles EINTR and counts > 2^31
Bruno Haible <bruno@clisp.org>
parents:
1431
diff
changeset
|
3 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7746
diff
changeset
|
4 This program is free software: you can redistribute it and/or modify |
4002
9fcf64c770ed
Orthogonal approach to read()/write() that handles EINTR and counts > 2^31
Bruno Haible <bruno@clisp.org>
parents:
1431
diff
changeset
|
5 it under the terms of the GNU General Public License as published by |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7746
diff
changeset
|
6 the Free Software Foundation; either version 3 of the License, or |
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7746
diff
changeset
|
7 (at your option) any later version. |
1324 | 8 |
4002
9fcf64c770ed
Orthogonal approach to read()/write() that handles EINTR and counts > 2^31
Bruno Haible <bruno@clisp.org>
parents:
1431
diff
changeset
|
9 This program is distributed in the hope that it will be useful, |
9fcf64c770ed
Orthogonal approach to read()/write() that handles EINTR and counts > 2^31
Bruno Haible <bruno@clisp.org>
parents:
1431
diff
changeset
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of |
9fcf64c770ed
Orthogonal approach to read()/write() that handles EINTR and counts > 2^31
Bruno Haible <bruno@clisp.org>
parents:
1431
diff
changeset
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
9fcf64c770ed
Orthogonal approach to read()/write() that handles EINTR and counts > 2^31
Bruno Haible <bruno@clisp.org>
parents:
1431
diff
changeset
|
12 GNU General Public License for more details. |
9fcf64c770ed
Orthogonal approach to read()/write() that handles EINTR and counts > 2^31
Bruno Haible <bruno@clisp.org>
parents:
1431
diff
changeset
|
13 |
9fcf64c770ed
Orthogonal approach to read()/write() that handles EINTR and counts > 2^31
Bruno Haible <bruno@clisp.org>
parents:
1431
diff
changeset
|
14 You should have received a copy of the GNU General Public License |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7746
diff
changeset
|
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
4002
9fcf64c770ed
Orthogonal approach to read()/write() that handles EINTR and counts > 2^31
Bruno Haible <bruno@clisp.org>
parents:
1431
diff
changeset
|
16 |
9fcf64c770ed
Orthogonal approach to read()/write() that handles EINTR and counts > 2^31
Bruno Haible <bruno@clisp.org>
parents:
1431
diff
changeset
|
17 #include <stddef.h> |
9fcf64c770ed
Orthogonal approach to read()/write() that handles EINTR and counts > 2^31
Bruno Haible <bruno@clisp.org>
parents:
1431
diff
changeset
|
18 |
7746
577c75e46325
* lib/safe-read.h [C++]: Wrap declarations in extern "C".
Jim Meyering <jim@meyering.net>
parents:
5848
diff
changeset
|
19 #ifdef __cplusplus |
577c75e46325
* lib/safe-read.h [C++]: Wrap declarations in extern "C".
Jim Meyering <jim@meyering.net>
parents:
5848
diff
changeset
|
20 extern "C" { |
577c75e46325
* lib/safe-read.h [C++]: Wrap declarations in extern "C".
Jim Meyering <jim@meyering.net>
parents:
5848
diff
changeset
|
21 #endif |
577c75e46325
* lib/safe-read.h [C++]: Wrap declarations in extern "C".
Jim Meyering <jim@meyering.net>
parents:
5848
diff
changeset
|
22 |
577c75e46325
* lib/safe-read.h [C++]: Wrap declarations in extern "C".
Jim Meyering <jim@meyering.net>
parents:
5848
diff
changeset
|
23 |
4045
4827e45aba29
(SAFE_READ_ERROR): Define.
Jim Meyering <jim@meyering.net>
parents:
4002
diff
changeset
|
24 #define SAFE_READ_ERROR ((size_t) -1) |
4827e45aba29
(SAFE_READ_ERROR): Define.
Jim Meyering <jim@meyering.net>
parents:
4002
diff
changeset
|
25 |
4002
9fcf64c770ed
Orthogonal approach to read()/write() that handles EINTR and counts > 2^31
Bruno Haible <bruno@clisp.org>
parents:
1431
diff
changeset
|
26 /* Read up to COUNT bytes at BUF from descriptor FD, retrying if interrupted. |
4045
4827e45aba29
(SAFE_READ_ERROR): Define.
Jim Meyering <jim@meyering.net>
parents:
4002
diff
changeset
|
27 Return the actual number of bytes read, zero for EOF, or SAFE_READ_ERROR |
4827e45aba29
(SAFE_READ_ERROR): Define.
Jim Meyering <jim@meyering.net>
parents:
4002
diff
changeset
|
28 upon error. */ |
4002
9fcf64c770ed
Orthogonal approach to read()/write() that handles EINTR and counts > 2^31
Bruno Haible <bruno@clisp.org>
parents:
1431
diff
changeset
|
29 extern size_t safe_read (int fd, void *buf, size_t count); |
7746
577c75e46325
* lib/safe-read.h [C++]: Wrap declarations in extern "C".
Jim Meyering <jim@meyering.net>
parents:
5848
diff
changeset
|
30 |
577c75e46325
* lib/safe-read.h [C++]: Wrap declarations in extern "C".
Jim Meyering <jim@meyering.net>
parents:
5848
diff
changeset
|
31 |
577c75e46325
* lib/safe-read.h [C++]: Wrap declarations in extern "C".
Jim Meyering <jim@meyering.net>
parents:
5848
diff
changeset
|
32 #ifdef __cplusplus |
577c75e46325
* lib/safe-read.h [C++]: Wrap declarations in extern "C".
Jim Meyering <jim@meyering.net>
parents:
5848
diff
changeset
|
33 } |
577c75e46325
* lib/safe-read.h [C++]: Wrap declarations in extern "C".
Jim Meyering <jim@meyering.net>
parents:
5848
diff
changeset
|
34 #endif |