]> sigrok.org Git - libsigrok.git/blobdiff - src/output/ols.c
fluke-45: free memory that was allocated by SCPI get routines
[libsigrok.git] / src / output / ols.c
index 78a41bb0b4645032eb342ef1796246d165b6da6b..2129658a346deaa1a48abcd6aab20d1c4e103619 100644 (file)
@@ -15,8 +15,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
 /*
  * https://github.com/jawi/ols/wiki/OLS-data-file-format
  */
 
+#include <config.h>
 #include <stdlib.h>
 #include <string.h>
 #include <glib.h>
-#include "libsigrok.h"
+#include <libsigrok/libsigrok.h>
 #include "libsigrok-internal.h"
 
 #define LOG_PREFIX "output/ols"
@@ -38,16 +38,14 @@ struct context {
        uint64_t num_samples;
 };
 
-static int init(struct sr_output *o)
+static int init(struct sr_output *o, GHashTable *options)
 {
        struct context *ctx;
 
-       if (!(ctx = g_try_malloc(sizeof(struct context)))) {
-               sr_err("%s: ctx malloc failed", __func__);
-               return SR_ERR_MALLOC;
-       }
-       o->internal = ctx;
+       (void)options;
 
+       ctx = g_malloc0(sizeof(struct context));
+       o->priv = ctx;
        ctx->samplerate = 0;
        ctx->num_samples = 0;
 
@@ -88,7 +86,7 @@ static GString *gen_header(const struct sr_dev_inst *sdi, struct context *ctx)
        return s;
 }
 
-static int receive(struct sr_output *o, const struct sr_datafeed_packet *packet,
+static int receive(const struct sr_output *o, const struct sr_datafeed_packet *packet,
                GString **out)
 {
        struct context *ctx;
@@ -102,7 +100,7 @@ static int receive(struct sr_output *o, const struct sr_datafeed_packet *packet,
        *out = NULL;
        if (!o || !o->sdi)
                return SR_ERR_ARG;
-       ctx = o->internal;
+       ctx = o->priv;
 
        switch (packet->type) {
        case SR_DF_META:
@@ -141,16 +139,20 @@ static int cleanup(struct sr_output *o)
        if (!o || !o->sdi)
                return SR_ERR_ARG;
 
-       ctx = o->internal;
+       ctx = o->priv;
        g_free(ctx);
-       o->internal = NULL;
+       o->priv = NULL;
 
        return SR_OK;
 }
 
-SR_PRIV struct sr_output_format output_ols = {
+SR_PRIV struct sr_output_module output_ols = {
        .id = "ols",
-       .description = "OpenBench Logic Sniffer",
+       .name = "OLS",
+       .desc = "OpenBench Logic Sniffer data",
+       .exts = (const char*[]){"ols", NULL},
+       .flags = 0,
+       .options = NULL,
        .init = init,
        .receive = receive,
        .cleanup = cleanup