]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Add nonnull attributes to trees.c functions. hinting
authorHans Kristian Rosbach <hk-git@circlestorm.org>
Sat, 7 May 2022 17:10:29 +0000 (19:10 +0200)
committerHans Kristian Rosbach <hk-git@circlestorm.org>
Sat, 7 May 2022 18:39:51 +0000 (20:39 +0200)
deflate.h
trees.c
zconf-ng.h.in
zconf.h.in

index b5ae2f8e665157a75fe36e92e05c9aa9f3d25f18..e04f90b319f9d7b244dea9a59ac6012496e85655 100644 (file)
--- a/deflate.h
+++ b/deflate.h
@@ -372,17 +372,17 @@ static inline void put_uint64(deflate_state *s, uint64_t lld) {
    memory checker errors from longest match routines */
 
 
-void Z_INTERNAL fill_window(deflate_state *s);
-void Z_INTERNAL slide_hash_c(deflate_state *s);
+void Z_INTERNAL fill_window(deflate_state *s) Z_NONULL;
+void Z_INTERNAL slide_hash_c(deflate_state *s) Z_NONULL;
 
         /* in trees.c */
-void Z_INTERNAL zng_tr_init(deflate_state *s);
-void Z_INTERNAL zng_tr_flush_block(deflate_state *s, char *buf, uint32_t stored_len, int last);
-void Z_INTERNAL zng_tr_flush_bits(deflate_state *s);
-void Z_INTERNAL zng_tr_align(deflate_state *s);
-void Z_INTERNAL zng_tr_stored_block(deflate_state *s, char *buf, uint32_t stored_len, int last);
+void Z_INTERNAL zng_tr_init(deflate_state *s) Z_NONULL;
+void Z_INTERNAL zng_tr_flush_block(deflate_state *s, char *buf, uint32_t stored_len, int last) Z_NONULL_A(1);
+void Z_INTERNAL zng_tr_flush_bits(deflate_state *s) Z_NONULL;
+void Z_INTERNAL zng_tr_align(deflate_state *s) Z_NONULL;
+void Z_INTERNAL zng_tr_stored_block(deflate_state *s, char *buf, uint32_t stored_len, int last) Z_NONULL_A(1);
 uint16_t Z_INTERNAL PREFIX(bi_reverse)(unsigned code, int len);
-void Z_INTERNAL PREFIX(flush_pending)(PREFIX3(streamp) strm);
+void Z_INTERNAL PREFIX(flush_pending)(PREFIX3(streamp) strm) Z_NONULL;
 #define d_code(dist) ((dist) < 256 ? zng_dist_code[dist] : zng_dist_code[256+((dist)>>7)])
 /* Mapping from a distance to a distance code. dist is the distance - 1 and
  * must not have side effects. zng_dist_code[256] and zng_dist_code[257] are never
diff --git a/trees.c b/trees.c
index 7bc70075b51f0838ff8ce53e07201dfa6c15734b..74fae7c8f50234c7711b473f8380d43e14a07274 100644 (file)
--- a/trees.c
+++ b/trees.c
@@ -65,17 +65,17 @@ static const static_tree_desc  static_bl_desc =
  * Local (static) routines in this file.
  */
 
-static void init_block       (deflate_state *s);
-static void pqdownheap       (deflate_state *s, ct_data *tree, int k);
-static void gen_bitlen       (deflate_state *s, tree_desc *desc);
-static void build_tree       (deflate_state *s, tree_desc *desc);
-static void scan_tree        (deflate_state *s, ct_data *tree, int max_code);
-static void send_tree        (deflate_state *s, ct_data *tree, int max_code);
-static int  build_bl_tree    (deflate_state *s);
-static void send_all_trees   (deflate_state *s, int lcodes, int dcodes, int blcodes);
-static void compress_block   (deflate_state *s, const ct_data *ltree, const ct_data *dtree);
-static int  detect_data_type (deflate_state *s);
-static void bi_flush         (deflate_state *s);
+static void init_block       (deflate_state *s) Z_NONULL;
+static void pqdownheap       (deflate_state *s, ct_data *tree, int k) Z_NONULL;
+static void gen_bitlen       (deflate_state *s, tree_desc *desc) Z_NONULL;
+static void build_tree       (deflate_state *s, tree_desc *desc) Z_NONULL;
+static void scan_tree        (deflate_state *s, ct_data *tree, int max_code) Z_NONULL;
+static void send_tree        (deflate_state *s, ct_data *tree, int max_code) Z_NONULL;
+static int  build_bl_tree    (deflate_state *s) Z_NONULL;
+static void send_all_trees   (deflate_state *s, int lcodes, int dcodes, int blcodes) Z_NONULL;
+static void compress_block   (deflate_state *s, const ct_data *ltree, const ct_data *dtree) Z_NONULL;
+static int  detect_data_type (deflate_state *s) Z_NONULL;
+static void bi_flush         (deflate_state *s) Z_NONULL;
 
 /* ===========================================================================
  * Initialize the tree data structures for a new zlib stream.
index 21629c7b30e91660b8fd67adf33e3fb5a1e1e6aa..95241dc2faee959304f9d9e1d4ee67f3a935f836 100644 (file)
@@ -168,4 +168,14 @@ typedef PTRDIFF_TYPE ptrdiff_t;
 #  endif
 #endif
 
+#if defined(__clang__) || defined(__GNUC__)
+#  define Z_NONULL __attribute__ ((nonnull))
+#  define Z_NONULL_A(...) __attribute__ ((nonnull(__VA_ARGS__)))
+#  define Z_RET_NONULL __attribute__ ((returns_nonnull))
+#else
+#  define Z_NONULL
+#  define Z_NONULL_A(...)
+#  define Z_RET_NONULL
+#endif
+
 #endif /* ZCONFNG_H */
index fef6bab42dbf6cb780431a28707da3bc5665bee6..e295880120c25aeaa728bc0957b7365d41da1273 100644 (file)
@@ -188,4 +188,14 @@ typedef PTRDIFF_TYPE ptrdiff_t;
 #  endif
 #endif
 
+#if defined(__clang__) || defined(__GNUC__)
+#  define Z_NONULL __attribute__ ((nonnull))
+#  define Z_NONULL_A(...) __attribute__ ((nonnull(__VA_ARGS__)))
+#  define Z_RET_NONULL __attribute__ ((returns_nonnull))
+#else
+#  define Z_NONULL
+#  define Z_NONULL_A(...)
+#  define Z_RET_NONULL
+#endif
+
 #endif /* ZCONF_H */