diff options
author | Mattias Andrée <maandree@kth.se> | 2016-07-11 13:35:11 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2016-07-11 13:35:11 +0200 |
commit | 3119fb1ec2aa6ce7aca87844ca0581cbf3c0d193 (patch) | |
tree | 0e3e2da41fad53a09b66b54f165142b0d5b0e22c /src/util.h | |
parent | Add get_pidfile_pathname (diff) | |
download | coopgammad-3119fb1ec2aa6ce7aca87844ca0581cbf3c0d193.tar.gz coopgammad-3119fb1ec2aa6ce7aca87844ca0581cbf3c0d193.tar.bz2 coopgammad-3119fb1ec2aa6ce7aca87844ca0581cbf3c0d193.tar.xz |
Implement use of PID file
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/util.h')
-rw-r--r-- | src/util.h | 23 |
1 files changed, 13 insertions, 10 deletions
@@ -15,8 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this library. If not, see <http://www.gnu.org/licenses/>. */ -#include <stdlib.h> -#include <string.h> +#include <stddef.h> @@ -28,12 +27,16 @@ * @return The duplicate of the memory segment, * `NULL` on error */ -static inline void* memdup(const void* src, size_t n) -{ - void* dest = malloc(n); - if (dest == NULL) - return NULL; - memcpy(dest, src, n); - return dest; -} +void* memdup(const void* src, size_t n); + + +/** + * Read an entire file + * + * @param fd The file descriptor + * @param n Output for the size of the file + * @return The read content, plus a NUL byte at + * the end (not counted in `*n`) + */ +void* nread(int fd, size_t* n); |