chiark / gitweb /
Compiles and links.
[adns.git] / src / query.c
index 7c977bb5a09c071335233ef5088f82b6932074c5..1d4dc5fd94df3753d7e9107a5630763482e6bf44 100644 (file)
@@ -158,23 +158,31 @@ void adns_cancel(adns_query query) {
   abort(); /* fixme */
 }
 
-void *adns__alloc_interim(adns_query qu, size_t sz) {
+static void *alloc_common(adns_query qu, size_t sz) {
   allocnode *an;
 
   if (!sz) return qu; /* Any old pointer will do */
   assert(!qu->final_allocspace);
-  sz= MEM_ROUND(sz);
   an= malloc(MEM_ROUND(MEM_ROUND(sizeof(*an)) + sz));
   if (!an) {
     adns__query_fail(qu,adns_s_nolocalmem);
     return 0;
   }
-  qu->interim_allocd += sz;
   an->next= qu->allocations;
   qu->allocations= an;
   return (byte*)an + MEM_ROUND(sizeof(*an));
 }
 
+void *adns__alloc_interim(adns_query qu, size_t sz) {
+  sz= MEM_ROUND(sz);
+  qu->interim_allocd += sz;
+  return alloc_common(qu,sz);
+}
+
+void *adns__alloc_mine(adns_query qu, size_t sz) {
+  return alloc_common(qu,MEM_ROUND(sz));
+}
+
 void *adns__alloc_final(adns_query qu, size_t sz) {
   /* When we're in the _final stage, we _subtract_ from interim_alloc'd
    * each allocation, and use final_allocspace to point to the next free