Commits

Benjamin Black committed 5d33c0e

Finished skein_update(), converted error codes to atoms, removed excess whitespace

  • Participants
  • Parent commits d517004

Comments (0)

Files changed (1)

 	    enif_release_resource(env, state);
 	    return enif_make_tuple2(env, enif_make_atom(env, "ok"), state);
 	} else {
-		return enif_make_tuple2(env, enif_make_atom(env, "error"), r);		
+		return enif_make_tuple2(env, enif_make_atom(env, "error"), enif_make_atom(env, r));
 	}
 }
 
 	enif_inspect_binary(env, argv[1], &bin);
 	
 	HashReturn r = Update(state, bin.data, bin.size * 8);
-	
-    return enif_make_atom(env, "ok");
+	if (r == SUCCESS) {
+	    enif_release_resource(env, state);
+	    return enif_make_tuple2(env, enif_make_atom(env, "ok"), state);
+	} else {
+		return enif_make_tuple2(env, enif_make_atom(env, "error"), enif_make_atom(env, r));
+	}
 }
 
 ERL_NIF_TERM skein_final(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
 	hashState *state = NULL;
 	enif_get_resource(env, argv[0], skein_hashstate, (void**)&state);
 	
-	BitSequence *hash = enif_alloc_resource(env, skein_hashval, sizeof(state->statebits / 8));;
+	BitSequence *hash = enif_alloc_resource(env, skein_hashval, sizeof(state->statebits / 8));
 	HashReturn r = Final(state, hash);
 	if (r == SUCCESS) {
 		ERL_NIF_TERM result = enif_make_resource(env, hash);
 	    return enif_make_tuple2(env, enif_make_atom(env, "ok"), hash);
 	} else {
 		free(hash);
-		return enif_make_tuple2(env, enif_make_atom(env, "error"), r);		
+		return enif_make_tuple2(env, enif_make_atom(env, "error"), enif_make_atom(env, r));
 	}
 }
 
 	ErlNifBinary bin;
 	enif_inspect_binary(env, argv[1], &bin);
 	
-	BitSequence *hash = enif_alloc_resource(env, skein_hashval, sizeof(bits / 8));;
+	BitSequence *hash = enif_alloc_resource(env, skein_hashval, sizeof(bits / 8));
 	HashReturn r = Hash(bits, (BitSequence *)(bin.data), bin.size * 8, hash);
 	if (r == SUCCESS) {
 		ERL_NIF_TERM result = enif_make_resource(env, hash);
 	    return enif_make_tuple2(env, enif_make_atom(env, "ok"), hash);
 	} else {
 		free(hash);
-		return enif_make_tuple2(env, enif_make_atom(env, "error"), r);		
+		return enif_make_tuple2(env, enif_make_atom(env, "error"), enif_make_atom(env, r));
 	}	
 }