]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
alloc_lite works
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Wed, 10 Mar 2010 11:01:33 +0000 (11:01 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Wed, 10 Mar 2010 11:01:33 +0000 (11:01 +0000)
git-svn-id: file:///svn/unbound/trunk@2015 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
libunbound/libworker.c
smallapp/unbound-host.c
testcode/asynclook.c
testcode/harvest.c
util/alloc.c
util/alloc.h

index 64c6fb6823cee5848cb47efe7b93e36f6d86de77..3d32cb21823e4f34bda3028de2582616c839afc7 100644 (file)
@@ -1,3 +1,6 @@
+10 March 2010: Wouter
+       - --enable-alloc-lite works with test set.
+
 9 March 2010: Wouter
        - tag 1.4.2 created.
        - trunk is 1.4.3 in development.
index 315a791b310df54557d573f7a8ad77556320c476..dc54b03a23babf3b15e31d8a99a7992500f76f8b 100644 (file)
@@ -484,8 +484,15 @@ setup_qinfo_edns(struct libworker* w, struct ctx_query* q,
        if(!rdf) {
                return 0;
        }
+#ifdef UNBOUND_ALLOC_LITE
+       qinfo->qname = memdup(ldns_rdf_data(rdf), ldns_rdf_size(rdf));
+       qinfo->qname_len = ldns_rdf_size(rdf);
+       ldns_rdf_deep_free(rdf);
+       rdf = 0;
+#else
        qinfo->qname = ldns_rdf_data(rdf);
        qinfo->qname_len = ldns_rdf_size(rdf);
+#endif
        edns->edns_present = 1;
        edns->ext_rcode = 0;
        edns->edns_version = 0;
index 5f32b7b710252880b87114958fc31beedfd9e63a..5b76f514319f69b7f89f3020853a0c0ef6439e68 100644 (file)
 #undef free
 #undef realloc
 #endif
+#ifdef UNBOUND_ALLOC_LITE
+#undef malloc
+#undef calloc
+#undef free
+#undef realloc
+#undef strdup
+char* unbound_lite_wrapstr(char* s) { return s; }
+#endif
 #include "libunbound/unbound.h"
 #include <ldns/ldns.h>
 
index c203f75a2bf59e78ce698e0c7dbf2d5fa04382f6..9ee4312dab0a9a943470307f1d6f0e5704616566 100644 (file)
 #include "libunbound/context.h"
 #include "util/locks.h"
 #include "util/log.h"
+#ifdef UNBOUND_ALLOC_LITE
+#undef malloc
+#undef calloc
+#undef realloc
+#undef free
+#undef strdup
+#endif
 
 /** keeping track of the async ids */
 struct track_id {
index f0b6f90c403856710e9c64dce168af0684034929..4f27dda6f9c87ad4d9f42d3444c71754210cd734 100644 (file)
 #ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
 #endif
+#ifdef UNBOUND_ALLOC_LITE
+#undef malloc
+#undef calloc
+#undef realloc
+#undef free
+#undef strdup
+char* unbound_lite_wrapstr(char* s) { return s; }
+#endif
 struct todo_item;
 struct labdata;
 
index d530aa4ffee8b85daf559edaeb3fa563beac36f5..be8d5b9f5e383c54badc049f71f8d426b457dcf1 100644 (file)
@@ -589,4 +589,50 @@ char* unbound_strdup_lite(const char* s, const char* file, int line,
        memmove(n, s, l);
        return n;
 }
+
+char* unbound_lite_wrapstr(char* s)
+{
+       char* n = unbound_strdup_lite(s, __FILE__, __LINE__, __func__);
+       free(s);
+       return n;
+}
+
+#undef ldns_pkt2wire
+ldns_status unbound_lite_pkt2wire(uint8_t **dest, const ldns_pkt *p, 
+       size_t *size)
+{
+       uint8_t* md = NULL;
+       size_t ms = 0;
+       ldns_status s = ldns_pkt2wire(&md, p, &ms);
+       if(md) {
+               *dest = unbound_stat_malloc_lite(ms, __FILE__, __LINE__, 
+                       __func__);
+               *size = ms;
+               if(!*dest) { free(md); return LDNS_STATUS_MEM_ERR; }
+               memcpy(*dest, md, ms);
+               free(md);
+       } else {
+               *dest = NULL;
+               *size = 0;
+       }
+       return s;
+}
+
+#undef i2d_DSA_SIG
+int unbound_lite_i2d_DSA_SIG(DSA_SIG* dsasig, unsigned char** sig)
+{
+       unsigned char* n = NULL;
+       int r= i2d_DSA_SIG(dsasig, &n);
+       if(n) {
+               *sig = unbound_stat_malloc_lite((size_t)r, __FILE__, __LINE__, 
+                       __func__);
+               if(!*sig) return -1;
+               memcpy(*sig, n, (size_t)r);
+               free(n);
+               return r;
+       }
+       *sig = NULL;
+       return r;
+}
+
 #endif /* UNBOUND_ALLOC_LITE */
index e0810afaa3b32bb04bc24eabb640ff677a0c8324..50da0c2ed23f0e661df2cfe95c3dda70454b0ea2 100644 (file)
@@ -195,6 +195,18 @@ void *unbound_stat_realloc_lite(void *ptr, size_t size, const char* file,
 #  define strdup(s) unbound_strdup_lite(s, __FILE__, __LINE__, __func__)
 char* unbound_strdup_lite(const char* s, const char* file, int line, 
        const char* func);
+char* unbound_lite_wrapstr(char* s);
+#  define ldns_rr2str(rr) unbound_lite_wrapstr(ldns_rr2str(rr))
+#  define ldns_rdf2str(rdf) unbound_lite_wrapstr(ldns_rdf2str(rdf))
+#  define ldns_rr_type2str(t) unbound_lite_wrapstr(ldns_rr_type2str(t))
+#  define ldns_rr_class2str(c) unbound_lite_wrapstr(ldns_rr_class2str(c))
+#  define ldns_rr_list2str(r) unbound_lite_wrapstr(ldns_rr_list2str(r))
+#  define ldns_pkt2str(p) unbound_lite_wrapstr(ldns_pkt2str(p))
+#  define ldns_pkt_rcode2str(r) unbound_lite_wrapstr(ldns_pkt_rcode2str(r))
+#  define ldns_pkt2wire(a, r, s) unbound_lite_pkt2wire(a, r, s)
+ldns_status unbound_lite_pkt2wire(uint8_t **dest, const ldns_pkt *p, size_t *size);
+#  define i2d_DSA_SIG(d, s) unbound_lite_i2d_DSA_SIG(d, s)
+int unbound_lite_i2d_DSA_SIG(DSA_SIG* dsasig, unsigned char** sig);
 #endif /* UNBOUND_ALLOC_LITE */
 
 #endif /* UTIL_ALLOC_H */