ziutek / rrd

Bindings to rrdtool
Other
147 stars 44 forks source link

return values from FetchResult as []float64 #18

Closed oec closed 9 years ago

oec commented 9 years ago

Suggested diff:

diff --git a/rrd_c.go b/rrd_c.go
index 348c017..9ff5a60 100644
--- a/rrd_c.go
+++ b/rrd_c.go
@@ -457,6 +457,14 @@ func (r *FetchResult) FreeValues() {
    C.free(unsafe.Pointer(sliceHeader.Data))
 }

+
+// Get a copy of the (c-)values of a FetchResult as slice
+func (r *FetchResult) GetValues() []float64 {
+   ret := make([]float64,len(r.values))
+   copy(ret,r.values)
+   return ret
+}
+
 // Export data from RRD file(s)
 func (e *Exporter) xport(start, end time.Time, step time.Duration) (XportResult, error) {
    cStart := C.time_t(start.Unix())
ziutek commented 9 years ago

I've just added Values method which does what you want. Please check last commit.