Permalink
Browse files

Fix for C89

  • Loading branch information...
h2so5 committed Jun 7, 2013
1 parent b951edc commit 05e2a6b0daf09adcb47097c7b4a4d7fe1fa05893
Showing with 8 additions and 4 deletions.
  1. +6 −3 src/mruby-sha2.c
  2. +2 −1 src/sha2.h
View
@@ -64,9 +64,10 @@ sha256_clone(mrb_state *mrb, mrb_value self)
{
SHA256_CTX *ctx = (SHA256_CTX*)DATA_PTR(self);
SHA256_CTX *ctx_copy = (SHA256_CTX*)mrb_malloc(mrb, sizeof(SHA256_CTX));
+ struct RData *c;
memcpy(ctx_copy, ctx, sizeof(SHA256_CTX));
- struct RData *c = mrb_data_object_alloc(mrb, sha256_class, ctx_copy, &sha256_type);
+ c = mrb_data_object_alloc(mrb, sha256_class, ctx_copy, &sha256_type);
return mrb_obj_value(c);
}
@@ -172,9 +173,10 @@ sha384_clone(mrb_state *mrb, mrb_value self)
{
SHA384_CTX *ctx = (SHA384_CTX*)DATA_PTR(self);
SHA384_CTX *ctx_copy = (SHA384_CTX*)mrb_malloc(mrb, sizeof(SHA384_CTX));
+ struct RData *c;
memcpy(ctx_copy, ctx, sizeof(SHA384_CTX));
- struct RData *c = mrb_data_object_alloc(mrb, sha384_class, ctx_copy, &sha384_type);
+ c = mrb_data_object_alloc(mrb, sha384_class, ctx_copy, &sha384_type);
return mrb_obj_value(c);
}
@@ -280,9 +282,10 @@ sha512_clone(mrb_state *mrb, mrb_value self)
{
SHA512_CTX *ctx = (SHA512_CTX*)DATA_PTR(self);
SHA512_CTX *ctx_copy = (SHA512_CTX*)mrb_malloc(mrb, sizeof(SHA512_CTX));
+ struct RData *c;
memcpy(ctx_copy, ctx, sizeof(SHA512_CTX));
- struct RData *c = mrb_data_object_alloc(mrb, sha512_class, ctx_copy, &sha512_type);
+ c = mrb_data_object_alloc(mrb, sha512_class, ctx_copy, &sha512_type);
return mrb_obj_value(c);
}
View
@@ -71,10 +71,11 @@ extern "C" {
* uintXX_t (from inttypes.h), you may need to define things by hand
* for your system:
*/
-#if 0
+#ifdef _WIN32
typedef unsigned char u_int8_t; /* 1-byte (8-bits) */
typedef unsigned int u_int32_t; /* 4-bytes (32-bits) */
typedef unsigned long long u_int64_t; /* 8-bytes (64-bits) */
+#define BYTE_ORDER LITTLE_ENDIAN
#endif
/*
* Most BSD systems already define u_intXX_t types, as does Linux.

0 comments on commit 05e2a6b

Please sign in to comment.