-void adns__query_nomem(adns_state ads, adns_query qu);
-void adns__query_finish(adns_state ads, adns_query qu, adns_status stat);
-void adns__query_fail(adns_state ads, adns_query qu, adns_status stat);
+int adns__internal_submit(adns_state ads, adns_query *query_r,
+ adns_rrtype type, char *query_dgram, int query_len,
+ adns_queryflags flags, struct timeval now,
+ adns_status failstat, const qcontext *ctx);
+/* Submits a query (for internal use, called during external submits).
+ *
+ * The new query is returned in *query_r, or we return adns_s_nomemory.
+ *
+ * The query datagram should already have been assembled; memory for it
+ * is taken over by this routine whether it succeeds or fails.
+ *
+ * If failstat is nonzero then if we are successful in creating the query
+ * it is immediately failed with code failstat (but _submit still succeds).
+ *
+ * ctx is copied byte-for-byte into the query.
+ */
+
+void *adns__alloc_interim(adns_query qu, size_t sz);
+/* Allocates some memory, and records which query it came from
+ * and how much there was.
+ *
+ * If an error occurs in the query, all its memory is simply freed.
+ *
+ * If the query succeeds, one large buffer will be made which is
+ * big enough for all these allocations, and then adns__alloc_final
+ * will get memory from this buffer.
+ *
+ * _alloc_interim can fail, in which case it will fail the query too,
+ * so nothing more need be done with it.
+ */
+
+void *adns__alloc_final(adns_query qu, size_t sz);
+/* Cannot fail.
+ */