aboutsummaryrefslogtreecommitdiffstats
path: root/src/util.h
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2016-07-11 13:35:11 +0200
committerMattias Andrée <maandree@kth.se>2016-07-11 13:35:11 +0200
commit3119fb1ec2aa6ce7aca87844ca0581cbf3c0d193 (patch)
tree0e3e2da41fad53a09b66b54f165142b0d5b0e22c /src/util.h
parentAdd get_pidfile_pathname (diff)
downloadcoopgammad-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 '')
-rw-r--r--src/util.h23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/util.h b/src/util.h
index 4f9cbde..c44164b 100644
--- a/src/util.h
+++ b/src/util.h
@@ -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);