aboutsummaryrefslogtreecommitdiffstats
path: root/src/util.h
diff options
context:
space:
mode:
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);