Skip to content

Commit

Permalink
Add destructors for element and fingerprint
Browse files Browse the repository at this point in the history
  • Loading branch information
itsravenous committed Sep 28, 2017
1 parent 797afa5 commit b3ea83f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Sources/i3s-swift/i3s-swift.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class Element {
e = Element_new()
}
deinit {
// TODO Element_delete(e)
Element_delete(e)
}
}

Expand All @@ -29,7 +29,7 @@ public class FingerPrint {
f = FingerPrint.do_init(ref: ref, data: data, nr: nr)
}
deinit {
// TODO FingerPrint_delete(f)
FingerPrint_delete(f)
}

public func compare(_ unknown: FingerPrint) -> Double {
Expand Down
8 changes: 8 additions & 0 deletions Sources/i3s/i3s.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,19 @@ extern "C" {
return new Element();
}

void Element_delete(Element *element) {
delete element;
}

FingerPrint* FingerPrint_new(const double *ref, const double *data, int nr) {
/* it's safe to cast away const: ref and data are not actually modified */
return new FingerPrint((double *)ref, (double *)data, nr);
}

void FingerPrint_delete(FingerPrint *fgp) {
delete fgp;
}

double FingerPrint_getScore(FingerPrint *fgp) {
return fgp->getScore();
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/i3s/incl_pub/i3s.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ typedef struct Element Element;
typedef struct FingerPrint FingerPrint;

Element* Element_new();
void Element_delete(Element *element);
FingerPrint* FingerPrint_new(const double *ref, const double *data, int nr);
void FingerPrint_delete(FingerPrint* fgp);
double FingerPrint_getScore(FingerPrint *fgp);
double Compare_two(FingerPrint* unknown, FingerPrint* fp);

Expand Down

0 comments on commit b3ea83f

Please sign in to comment.