summaryrefslogtreecommitdiff
path: root/patch.go
diff options
context:
space:
mode:
authorJesse Ezell <[email protected]>2014-03-20 21:56:41 -0700
committerJesse Ezell <[email protected]>2014-03-20 21:56:41 -0700
commitd0b334b24409ddc190a7010be0072d87df6b6bfe (patch)
treefb434c1f8182296b2a80bdf1939e09ddca021e68 /patch.go
parent9acd67e388b6fccf982c9206dc5326ae35c13f49 (diff)
cleanup and refactor diff / patch
Diffstat (limited to 'patch.go')
-rw-r--r--patch.go15
1 files changed, 11 insertions, 4 deletions
diff --git a/patch.go b/patch.go
index 561786e..f2016c4 100644
--- a/patch.go
+++ b/patch.go
@@ -12,7 +12,7 @@ type Patch struct {
ptr *C.git_patch
}
-func newPatch(ptr *C.git_patch) *Patch {
+func newPatchFromC(ptr *C.git_patch) *Patch {
if ptr == nil {
return nil
}
@@ -25,13 +25,20 @@ func newPatch(ptr *C.git_patch) *Patch {
return patch
}
-func (patch *Patch) Free() {
+func (patch *Patch) Free() error {
+ if patch.ptr == nil {
+ return ErrInvalid
+ }
runtime.SetFinalizer(patch, nil)
C.git_patch_free(patch.ptr)
+ return nil
}
-func (patch *Patch) String() string {
+func (patch *Patch) String() (string, error) {
+ if diff.ptr != nil {
+ return "", ErrInvalid
+ }
var cptr *C.char
C.git_patch_to_str(&cptr, patch.ptr)
- return C.GoString(cptr)
+ return C.GoString(cptr), nil
}