changeset 3:9c6b686f797d

misc: add extern C for C++ friends
author David Demelier <markand@malikania.fr>
date Thu, 29 Oct 2020 17:40:28 +0100
parents 3665a56a00aa
children b0ede725abca
files Makefile buf.h
diffstat 2 files changed, 23 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Thu Oct 29 17:30:46 2020 +0100
+++ b/Makefile	Thu Oct 29 17:40:28 2020 +0100
@@ -87,6 +87,9 @@
 	rm -f libbuf.a ${OBJS}
 	rm -f ${TESTS_OBJS}
 
+doxygen:
+	doxygen Doxyfile
+
 install:
 	mkdir -p ${DESTDIR}${INCDIR}
 	mkdir -p ${DESTDIR}${LIBDIR}
@@ -100,4 +103,4 @@
 test: ${TESTS_OBJS}
 	for t in ${TESTS_OBJS}; do ./$$t; done
 
-.PHONY: all clean install test
+.PHONY: all clean doxygen install test
--- a/buf.h	Thu Oct 29 17:30:46 2020 +0100
+++ b/buf.h	Thu Oct 29 17:40:28 2020 +0100
@@ -62,18 +62,31 @@
  * - BUF_FREE: defaults to free
  */
 
+/**
+ * \brief Function to allocate memory (defaults to malloc).
+ */
 #if !defined(BUF_MALLOC)
 #	define BUF_MALLOC malloc
 #endif
 
+/**
+ * \brief Function to reallocate memory (defaults to realloc).
+ */
 #if !defined(BUF_REALLOC)
 #	define BUF_REALLOC realloc
 #endif
 
+/**
+ * \brief Function to free memory (defaults to free).
+ */
 #if !defined(BUF_FREE)
 #	define BUF_FREE free
 #endif
 
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
 /**
  * \brief Buffer structure.
  *
@@ -122,7 +135,7 @@
  * Resize the string and sets character into the new storage area if needed.
  *
  * In contrast to \ref buf_reserve, this function change the string length
- * and update the new storage with the given character. if the new size is
+ * and update the new storage with the given character. If the new size is
  * smaller then only length is updated, otherwise new memory can be reallocated
  * if needed.
  *
@@ -131,7 +144,7 @@
  *
  * \pre b != NULL
  * \param b the buffer to grow
- * \param desired the additional space to request
+ * \param size the new size to set
  * \param c the character to fill (use '\0' if not needed)
  * \return false on error and sets errno
  */
@@ -270,4 +283,8 @@
 void
 buf_finish(struct buf *b);
 
+#if defined(__cplusplus)
+}
+#endif
+
 #endif /* !BUF_H */