Skip to content

Commit

Permalink
using OutOfMemory error from error package
Browse files Browse the repository at this point in the history
  • Loading branch information
daddinuz committed May 3, 2018
1 parent 74cd059 commit 0f87505
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
9 changes: 4 additions & 5 deletions examples/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,16 @@
#include <assert.h>
#include <result.h>

const Error OutOfMemoryError = Error_new("Out of memory");
const Error TooLongError = Error_new("Too long");
const Error StringTooLong = Error_new("Too long");

ResultOf(char *, OutOfMemoryError, TooLongError) SmallString_new(const char *literal) {
ResultOf(char *, OutOfMemoryError, StringTooLong) SmallString_new(const char *literal) {
assert(literal);
char *temporary;
if (strlen(literal) > 32) {
return Result_error(TooLongError);
return Result_error(StringTooLong);
}
if (!(temporary = strdup(literal))) {
return Result_error(OutOfMemoryError);
return Result_error(OutOfMemory);
}
return Result_ok(temporary);
}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "result",
"repo": "daddinuz/result",
"version": "0.1.0",
"version": "0.1.1",
"license": "MIT",
"description": "Result type resembling Rust's Result.",
"keywords": [
Expand All @@ -13,7 +13,7 @@
"sources/result.c"
],
"dependencies": {
"daddinuz/error": "0.1.0",
"daddinuz/error": "0.1.1",
"daddinuz/panic": "0.1.0"
},
"makefile": "result.cmake"
Expand Down
2 changes: 1 addition & 1 deletion sources/result.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include <panic/panic.h>
#include "result.h"

#define _STR(x) #x
#define _STR(x) #x
#define STR(x) _STR(x)

const char *Result_version(void) {
Expand Down
4 changes: 2 additions & 2 deletions sources/result.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ extern "C" {

#define RESULT_VERSION_MAJOR 0
#define RESULT_VERSION_MINOR 1
#define RESULT_VERSION_PATCH 0
#define RESULT_VERSION_PATCH 1
#define RESULT_VERSION_SUFFIX ""
#define RESULT_VERSION_IS_RELEASE 0
#define RESULT_VERSION_HEX 0x000100
#define RESULT_VERSION_HEX 0x000101

/**
* @return The semantic versioning string of the package.
Expand Down

0 comments on commit 0f87505

Please sign in to comment.