Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed the typemap and also a memory bug in viterbi function in HMM.xs

svn path=/bioperl-ext/trunk/; revision=15942
  • Loading branch information...
commit 34d089a84c3ca4b66f23f680858629c20cda4cd4 1 parent ca1f84e
ymc authored
Showing with 8 additions and 10 deletions.
  1. +6 −8 Bio/Ext/HMM/HMM.xs
  2. +2 −2 Bio/Ext/HMM/typemap
View
14 Bio/Ext/HMM/HMM.xs
@@ -19,7 +19,7 @@ HMM_statistical_training(class, hmm, obs, hs)
HMM * hmm
SV * obs
SV * hs
- PPCODE:
+ CODE:
AV * obs_av = (AV *) SvRV(obs);
AV * hs_av = (AV *) SvRV(hs);
int i;
@@ -105,7 +105,7 @@ HMM_viterbi(class, hmm, seq)
PPCODE:
SV * sv;
int T = strlen(seq);
- char * hss = (char *) malloc(T*sizeof(char));
+ char * hss = (char *) malloc((T+1)*sizeof(char));
char obs[T+1];
if (hss == NULL)
croak("Can't allocate memory for hidden state sequence!\n");
@@ -124,12 +124,10 @@ new(class, symbols, states)
char * class
char * symbols
char * states
- PPCODE:
- HMM * out;
- out = HMM_new(symbols, states);
- ST(0) = sv_newmortal();
- sv_setref_pv(ST(0), class, (void *) out);
- XSRETURN(1);
+ CODE:
+ RETVAL = HMM_new(symbols, states);
+ OUTPUT:
+ RETVAL
double
get_init_entry(class, hmm, state)
View
4 Bio/Ext/HMM/typemap
@@ -3,8 +3,8 @@ HMM * T_HMM
INPUT
T_HMM
- $var = ($type) (SvROK($arg) == 0 ? ($type) NULL : ($type) SvIV((SV*)SvRV($arg)))
+ $var = INT2PTR(HMM *, (SvIV((SV*)SvRV($arg))));
OUTPUT
T_HMM
- sv_setref_pv($arg, "Bio::Ext::HMM::HMM", (void*) $var);
+ sv_setref_pv($arg, "Bio::Ext::HMM::HMM", (void *) $var);
Please sign in to comment.
Something went wrong with that request. Please try again.