diff options
author | Andrew Tridgell <tridge@samba.org> | 2004-09-29 06:31:14 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:59:29 -0500 |
commit | 4f13ebef5d6711ac121b9c41e2fbbe2cd3b6da0e (patch) | |
tree | 9c97145fdcde8e5e7d9d2736b0571caae530db7e /source4/include | |
parent | 173b61817b23c7338a30cae819cc63879543587f (diff) | |
download | samba-4f13ebef5d6711ac121b9c41e2fbbe2cd3b6da0e.tar.gz samba-4f13ebef5d6711ac121b9c41e2fbbe2cd3b6da0e.tar.bz2 samba-4f13ebef5d6711ac121b9c41e2fbbe2cd3b6da0e.zip |
r2744: ben elliston taught me about gcov today, which allows you to measure
the % coverage in terms of lines of code of a test suite. I thought a
good first place to start with gcov was the talloc test suite. When I
started the test suite covered about 60% of all lines of code in
talloc.c, and now it covers about 99%. The only lines not covered are
talloc corruption errors, as that would cause smb_panic() to fire.
It will be interesting to try gcov on the main Samba test suite for
smbd. We won't achieve 100% coverage, but it would be nice to get to
90% or more.
I also modified the talloc.c sources to be able to be build standalone, using:
gcc -c -D_STANDALONE_ -Iinlcude lib/talloc.c
that should make it much easier to re-use talloc in other projects
(This used to be commit 8d4dc99b82efdf24b6811851c7bdd4af5a4c52c9)
Diffstat (limited to 'source4/include')
-rw-r--r-- | source4/include/includes.h | 4 | ||||
-rw-r--r-- | source4/include/talloc.h | 39 |
2 files changed, 42 insertions, 1 deletions
diff --git a/source4/include/includes.h b/source4/include/includes.h index d29353cafc..06e9b91347 100644 --- a/source4/include/includes.h +++ b/source4/include/includes.h @@ -1068,7 +1068,9 @@ time_t timegm(struct tm *tm); #include <sys/xattr.h> #endif -#define discard_const_p(type, ptr) (type *)discard_const(ptr) +#define discard_const_p(type, ptr) ((type *)discard_const(ptr)) + +#define TALLOC_ABORT(reason) smb_panic(reason) #endif /* _INCLUDES_H */ diff --git a/source4/include/talloc.h b/source4/include/talloc.h index 4c108d865d..2e0cca7070 100644 --- a/source4/include/talloc.h +++ b/source4/include/talloc.h @@ -49,5 +49,44 @@ typedef void TALLOC_CTX; #define data_blob(ptr, size) data_blob_named(ptr, size, __location__) #define data_blob_talloc(ctx, ptr, size) data_blob_talloc_named(ctx, ptr, size, __location__) +#ifndef PRINTF_ATTRIBUTE +#define PRINTF_ATTRIBUTE(a1, a2) +#endif + + +/* The following definitions come from lib/talloc.c */ +void *_talloc(const void *context, size_t size); +void talloc_set_destructor(const void *ptr, int (*destructor)(void *)); +void talloc_increase_ref_count(const void *ptr); +void *talloc_reference(const void *context, const void *ptr); +void *talloc_unreference(const void *context, const void *ptr); +void talloc_set_name(const void *ptr, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); +void talloc_set_name_const(const void *ptr, const char *name); +void *talloc_named(const void *context, size_t size, + const char *fmt, ...) PRINTF_ATTRIBUTE(3,4); +void *talloc_named_const(const void *context, size_t size, const char *name); +const char *talloc_get_name(const void *ptr); +void *talloc_init(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2); +int talloc_free(void *ptr); +void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *name); +void *talloc_steal(const void *new_ctx, const void *ptr); +off_t talloc_total_size(const void *ptr); +off_t talloc_total_blocks(const void *ptr); +void talloc_report_full(const void *ptr, FILE *f); +void talloc_report(const void *ptr, FILE *f); +void talloc_enable_leak_report(void); +void talloc_enable_leak_report_full(void); +void *talloc_zero(const void *ctx, size_t size); +void *_talloc_memdup(const void *t, const void *p, size_t size, const char *name); +char *talloc_strdup(const void *t, const char *p); +char *talloc_strndup(const void *t, const char *p, size_t n); +char *talloc_vasprintf(const void *t, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); +char *talloc_asprintf(const void *t, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); +char *talloc_asprintf_append(char *s, + const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); +void *talloc_array(const void *ctx, size_t el_size, unsigned count, const char *name); +void *talloc_realloc_array(const void *ctx, void *ptr, size_t el_size, unsigned count, const char *name); +void *talloc_ldb_alloc(void *context, void *ptr, size_t size); + #endif |