1. Allocating scructures with (aligned) bool attributes with LDNS_CALLOC (that fills the freshly allocated struct with zero's)
2. signed char as a fall back type for bool, as recommended in the autoconf manual
3. An access function for the is_glueattribute: bool ldns_dnssec_name_is_glue(ldns_dnssec_name *name)
--- /dev/null
+/* Just a replacement, if the original malloc is not
+ GNU-compliant. See autoconf documentation. */
+
+#if HAVE_CONFIG_H
+#include <ldns/config.h>
+#endif
+
+void *calloc();
+
+#if !HAVE_BZERO && HAVE_MEMSET
+# define bzero(buf, bytes) ((void) memset (buf, 0, bytes))
+#endif
+
+void *
+calloc(size_t num, size_t size)
+{
+ void *new = malloc(num * size);
+ if (!new) {
+ return NULL;
+ }
+ bzero(new, num * size);
+ return new;
+}
+
# Checks for header files.
AC_HEADER_STDC
+AC_HEADER_STDBOOL
#AC_HEADER_SYS_WAIT
#AC_CHECK_HEADERS([getopt.h fcntl.h stdlib.h string.h strings.h unistd.h])
# do the very minimum - we can always extend this
-AC_CHECK_HEADERS([getopt.h stdarg.h stdbool.h openssl/ssl.h netinet/in.h time.h arpa/inet.h netdb.h],,, [AC_INCLUDES_DEFAULT])
+AC_CHECK_HEADERS([getopt.h stdarg.h openssl/ssl.h netinet/in.h time.h arpa/inet.h netdb.h],,, [AC_INCLUDES_DEFAULT])
AC_CHECK_HEADERS(sys/param.h sys/mount.h,,,
[AC_INCLUDES_DEFAULT
[
AC_REPLACE_FUNCS(b64_ntop)
AC_REPLACE_FUNCS(b32_pton)
AC_REPLACE_FUNCS(b32_ntop)
+AC_REPLACE_FUNCS(calloc)
AC_REPLACE_FUNCS(timegm)
AC_REPLACE_FUNCS(gmtime_r)
AC_REPLACE_FUNCS(ctime_r)
AC_REPLACE_FUNCS(snprintf)
AC_REPLACE_FUNCS(strlcpy)
AC_REPLACE_FUNCS(memmove)
-AC_CHECK_FUNCS([endprotoent endservent sleep random fcntl strtoul])
+AC_CHECK_FUNCS([endprotoent endservent sleep random fcntl strtoul bzero memset])
ACX_CHECK_GETADDRINFO_WITH_INCLUDES
if test $ac_cv_func_getaddrinfo = no; then
ldns_dnssec_data_chain *
ldns_dnssec_data_chain_new()
{
- ldns_dnssec_data_chain *nc = LDNS_XMALLOC(ldns_dnssec_data_chain, 1);
+ ldns_dnssec_data_chain *nc = LDNS_CALLOC(ldns_dnssec_data_chain, 1);
if(!nc) return NULL;
+ /*
+ * not needed anymore because of CALLOC
+
nc->rrset = NULL;
nc->parent_type = 0;
nc->parent = NULL;
nc->packet_rcode = 0;
nc->packet_qtype = 0;
nc->packet_nodata = false;
+
+ */
return nc;
}
{
ldns_dnssec_name *new_name;
- new_name = LDNS_MALLOC(ldns_dnssec_name);
+ new_name = LDNS_CALLOC(ldns_dnssec_name, 1);
if (!new_name) {
return NULL;
}
+ /*
+ * not needed anymore because of CALLOC
new_name->name = NULL;
new_name->rrsets = NULL;
new_name->is_glue = false;
new_name->hashed_name = NULL;
+ */
return new_name;
}
return NULL;
}
+bool
+ldns_dnssec_name_is_glue(ldns_dnssec_name *name)
+{
+ if (name) {
+ return name->is_glue;
+ }
+ return false;
+}
+
void
ldns_dnssec_name_set_name(ldns_dnssec_name *rrset,
ldns_rdf *dname)
#ifndef LDNS_COMMON_H
#define LDNS_COMMON_H
-#if !defined(__cplusplus) && !defined(__bool_true_false_are_defined)
-
-#if defined(HAVE_STDBOOL_H)
-#include <stdbool.h>
+#ifdef HAVE_STDBOOL_H
+# include <stdbool.h>
#else
-
-/*@ignore@*/
-/* splint barfs on this construct */
-typedef unsigned int bool;
-#define bool bool
-#define false 0
-#define true 1
-#define __bool_true_false_are_defined 1
-/*@end@*/
-
-#endif
-
+# ifndef HAVE__BOOL
+# ifdef __cplusplus
+typedef bool _Bool;
+# else
+# define _Bool signed char
+# endif
+# endif
+# define bool _Bool
+# define false 0
+# define true 1
+# define __bool_true_false_are_defined 1
#endif
#ifdef HAVE_ATTR_FORMAT
*/
void ldns_dnssec_name_set_name(ldns_dnssec_name *name,
ldns_rdf *dname);
+/**
+ * Returns if dnssec_name structure is marked as glue.
+ * Note that the ldns_dnssec_zone_mark_glue function has to be called
+ * on a zone before using this function.
+ *
+ * \param[in] name the dnssec name to get the domain name from
+ * \return true if the structure is marked as glue, false otherwise.
+ */
+bool ldns_dnssec_name_is_glue(ldns_dnssec_name *name);
/**
* Sets the NSEC(3) RR of the given dnssec_name structure