Make Name.h use externally allocated components array
diff --git a/Makefile.am b/Makefile.am
index b51d0c4..fb62ca2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -14,7 +14,7 @@
bin_PROGRAMS = test-encode-decode-interest
ndn_cpp_a_SOURCES = ndn-cpp/common.h ndn-cpp/config.h \
- ndn-cpp/Name.cpp ndn-cpp/Name.hpp \
+ ndn-cpp/Name.cpp ndn-cpp/Name.h ndn-cpp/Name.hpp \
ndn-cpp/data.cc ndn-cpp/data.h \
ndn-cpp/interest.cc ndn-cpp/interest.h \
ndn-cpp/fields/blob.h \
diff --git a/Makefile.in b/Makefile.in
index 7ca10a4..042bbe0 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -387,7 +387,7 @@
ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS}
lib_LIBRARIES = ndn-cpp.a
ndn_cpp_a_SOURCES = ndn-cpp/common.h ndn-cpp/config.h \
- ndn-cpp/Name.cpp ndn-cpp/Name.hpp \
+ ndn-cpp/Name.cpp ndn-cpp/Name.h ndn-cpp/Name.hpp \
ndn-cpp/data.cc ndn-cpp/data.h \
ndn-cpp/interest.cc ndn-cpp/interest.h \
ndn-cpp/fields/blob.h \
diff --git a/ndn-cpp/Name.h b/ndn-cpp/Name.h
index 314d51a..a80e3d5 100644
--- a/ndn-cpp/Name.h
+++ b/ndn-cpp/Name.h
@@ -12,8 +12,8 @@
#endif
struct ndn_NameComponent {
- unsigned char *value;
- unsigned int valueLength;
+ unsigned char *value; /**< pointer to the component value */
+ unsigned int valueLength; /**< the number of bytes in value */
};
static inline void ndn_NameComponent_init(struct ndn_NameComponent *self, unsigned char *value, unsigned int valueLength)
@@ -21,18 +21,23 @@
self->value = value;
self->valueLength = valueLength;
}
-
-enum {
- ndn_Name_MAX_COMPONENTS = 100
-};
struct ndn_Name {
- struct ndn_NameComponent components[ndn_Name_MAX_COMPONENTS];
- unsigned int nComponents;
+ struct ndn_NameComponent *components; /**< pointer to the array of components. */
+ unsigned int maxComponents; /**< the number of elements in the allocated components array */
+ unsigned int nComponents; /**< the number of components in the name */
};
-static inline void ndn_Name_init(struct ndn_Name *self)
+/**
+ * Initialize an ndn_Name struct with the components array.
+ * @param self pointer to the ndn_Name struct
+ * @param components the array of ndn_NameComponent already allocated
+ * @param maxComponents the number of elements in the allocated components array
+ */
+static inline void ndn_Name_init(struct ndn_Name *self, struct ndn_NameComponent *components, unsigned int maxComponents)
{
+ self->components = components;
+ self->maxComponents = maxComponents;
self->nComponents = 0;
}
@@ -40,5 +45,5 @@
}
#endif
-#endif /* NAME_H */
+#endif