PuzzleD

D Interface to libpuzzle
git clone git://xatko.vsos.ethz.ch/PuzzleD.git
Log | Files | Refs

commit 092ea94561be77dc7526de6a0cc11bef836a7331
parent 31067621f4355da9229a1008e1026d3d32a9b359
Author: Dominik Schmidt <das1993@hotmail.com>
Date:   Thu, 27 Aug 2015 12:12:33 +0200

Check if the context is valid before freeing the vectors

This allows Vector initialization from outside the library.

Diffstat:
puzzle.d | 12+++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/puzzle.d b/puzzle.d @@ -134,7 +134,9 @@ struct DVec{ puzzle_init_dvec(ctx,&vec); } ~this(){ - puzzle_free_dvec(ctx,&vec); + if(ctx!=null){ + puzzle_free_dvec(ctx,&vec); + } } void load(string f){ if(puzzle_fill_dvec_from_file(ctx, &vec, toStringz(f))!=0){ @@ -172,7 +174,9 @@ struct CVec{ puzzle_init_cvec(ctx,&vec); } ~this(){ - puzzle_free_cvec(ctx,&vec); + if(ctx!=null){ + puzzle_free_cvec(ctx,&vec); + } } void load(string f){ if(puzzle_fill_cvec_from_file(ctx, &vec, toStringz(f))!=0){ @@ -211,7 +215,9 @@ struct CVec_Compressed{ puzzle_init_compressed_cvec(ctx,&vec); } ~this(){ - puzzle_free_compressed_cvec(ctx,&vec); + if(ctx!=null){ + puzzle_free_compressed_cvec(ctx,&vec); + } } CVec uncompress(){ return CVec(this);