aboutsummaryrefslogtreecommitdiff
path: root/src/common/container.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2006-08-11 07:09:17 +0000
committerNick Mathewson <nickm@torproject.org>2006-08-11 07:09:17 +0000
commit09a895e222f446d400337a3b65b8563705364ec0 (patch)
tree28329a7eeb802fe270e7a3bde2aaf26ff0de2f3d /src/common/container.h
parentb07525d316c6121d86bb8fa9664326f9b160604c (diff)
downloadtor-09a895e222f446d400337a3b65b8563705364ec0.tar
tor-09a895e222f446d400337a3b65b8563705364ec0.tar.gz
r7324@Kushana: nickm | 2006-08-10 23:23:15 -0700
Add more warnings to the list of those we tolerate. Start using GCC attributes more, for better error checking and better code generation. svn:r7020
Diffstat (limited to 'src/common/container.h')
-rw-r--r--src/common/container.h20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/common/container.h b/src/common/container.h
index 85072e644..6e266fead 100644
--- a/src/common/container.h
+++ b/src/common/container.h
@@ -32,10 +32,10 @@ void smartlist_remove(smartlist_t *sl, const void *element);
void *smartlist_pop_last(smartlist_t *sl);
void smartlist_reverse(smartlist_t *sl);
void smartlist_string_remove(smartlist_t *sl, const char *element);
-int smartlist_isin(const smartlist_t *sl, const void *element);
-int smartlist_string_isin(const smartlist_t *sl, const char *element);
-int smartlist_string_num_isin(const smartlist_t *sl, int num);
-int smartlist_overlap(const smartlist_t *sl1, const smartlist_t *sl2);
+int smartlist_isin(const smartlist_t *sl, const void *element) ATTR_PURE;
+int smartlist_string_isin(const smartlist_t *sl, const char *element) ATTR_PURE;
+int smartlist_string_num_isin(const smartlist_t *sl, int num) ATTR_PURE;
+int smartlist_overlap(const smartlist_t *sl1, const smartlist_t *sl2) ATTR_PURE;
void smartlist_intersect(smartlist_t *sl1, const smartlist_t *sl2);
void smartlist_subtract(smartlist_t *sl1, const smartlist_t *sl2);
@@ -43,13 +43,13 @@ void smartlist_subtract(smartlist_t *sl1, const smartlist_t *sl2);
#ifdef DEBUG_SMARTLIST
/** Return the number of items in sl.
*/
-extern INLINE int smartlist_len(const smartlist_t *sl) {
+extern INLINE int smartlist_len(const smartlist_t *sl) ATTR_PURE {
tor_assert(sl);
return (sl)->num_used;
}
/** Return the <b>idx</b>th element of sl.
*/
-extern INLINE void *smartlist_get(const smartlist_t *sl, int idx) {
+extern INLINE void *smartlist_get(const smartlist_t *sl, int idx) ATTR_PURE {
tor_assert(sl);
tor_assert(idx>=0);
tor_assert(sl->num_used < idx);
@@ -75,7 +75,8 @@ void smartlist_sort(smartlist_t *sl,
void smartlist_sort_strings(smartlist_t *sl);
void smartlist_sort_digests(smartlist_t *sl);
void *smartlist_bsearch(smartlist_t *sl, const void *key,
- int (*compare)(const void *key, const void **member));
+ int (*compare)(const void *key, const void **member))
+ ATTR_PURE;
void smartlist_pqueue_add(smartlist_t *sl,
int (*compare)(const void *a, const void *b),
@@ -90,9 +91,10 @@ void smartlist_pqueue_assert_ok(smartlist_t *sl,
int smartlist_split_string(smartlist_t *sl, const char *str, const char *sep,
int flags, int max);
char *smartlist_join_strings(smartlist_t *sl, const char *join, int terminate,
- size_t *len_out);
+ size_t *len_out) ATTR_MALLOC;
char *smartlist_join_strings2(smartlist_t *sl, const char *join,
- size_t join_len, int terminate, size_t *len_out);
+ size_t join_len, int terminate, size_t *len_out)
+ ATTR_MALLOC;
/** Iterate over the items in a smartlist <b>sl</b>, in order. For each item,
* assign it to a new local variable of type <b>type</b> named <b>var</b>, and