On 22.03.2017 00:43, Grazvydas Ignotas wrote:
Rather than using 3 different ways to wrap _mesa_sha1_*() to SHA1*()
functions (a macro, prototype with implementation in .c and an inline
function), make all 3 inline functions.

Signed-off-by: Grazvydas Ignotas <nota...@gmail.com>

Reviewed-by: Nicolai Hähnle <nicolai.haeh...@amd.com>

I noticed that a define is used for mesa_sha1. I wouldn't mind a change to

typedef struct _SHA1_CTX *mesa_sha1;

even though that would imply more changes throughout the code base. Might be best to delay until some of the disk cache uses have settled, and it's obviously not high priority.

Cheers,
Nicolai

---
 src/util/mesa-sha1.c |  6 ------
 src/util/mesa-sha1.h | 13 ++++++++++---
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/src/util/mesa-sha1.c b/src/util/mesa-sha1.c
index a14fec9..fa92846 100644
--- a/src/util/mesa-sha1.c
+++ b/src/util/mesa-sha1.c
@@ -26,16 +26,10 @@

 #include "sha1/sha1.h"
 #include "mesa-sha1.h"

 void
-_mesa_sha1_update(struct mesa_sha1 *ctx, const void *data, int size)
-{
-   SHA1Update(ctx, data, size);
-}
-
-void
 _mesa_sha1_compute(const void *data, size_t size, unsigned char result[20])
 {
    struct mesa_sha1 ctx;

    _mesa_sha1_init(&ctx);
diff --git a/src/util/mesa-sha1.h b/src/util/mesa-sha1.h
index ecbc708..a81aba9 100644
--- a/src/util/mesa-sha1.h
+++ b/src/util/mesa-sha1.h
@@ -30,14 +30,21 @@
 extern "C" {
 #endif

 #define mesa_sha1 _SHA1_CTX

-#define _mesa_sha1_init SHA1Init
+static inline void
+_mesa_sha1_init(struct mesa_sha1 *ctx)
+{
+   SHA1Init(ctx);
+}

-void
-_mesa_sha1_update(struct mesa_sha1 *ctx, const void *data, int size);
+static inline void
+_mesa_sha1_update(struct mesa_sha1 *ctx, const void *data, size_t size)
+{
+   SHA1Update(ctx, (const unsigned char *)data, size);
+}

 static inline void
 _mesa_sha1_final(struct mesa_sha1 *ctx, unsigned char result[20])
 {
    SHA1Final(result, ctx);


_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to