Author Message

I've been fooling around a lot with usersub.  I've managed to hook
some things in, but I think I've got a memory leak.  I ran a perl
program to check for leaks by calling my usersub in an infinite loop.
It ran out of memory after around 180,000 calls.  Here's my code - if
there's something obviously wrong, I'd really appreciate some advice!

p.s.  do_tval does *no* memory allocation at all.

case US_tv:
    if (items < 7)
      fatal("Usage &tv($descr,$ul,$strike,$tex,$vola,$rfr,$divyld [,$hints])");
    else {
        char *   descr  = (char *) str_get(st[1]);
        double   ul     = (double) str_gnum(st[2]);
        double   strike = (double) str_gnum(st[3]);
        double   tex    = (double) str_gnum(st[4]);
        double   vola   = (double) str_gnum(st[5]);
        double   rfr    = (double) str_gnum(st[6]);
        double   divyld = (double) str_gnum(st[7]);
        TvHints  hints  = 0;
        TvTheoValue tv;

        if (items > 7)
            hints = (TvHints) str_gnum(st[8]);

        if (!do_tval(descr,ul,strike,tex,vola,rfr,divyld, hints, &tv))
            fatal("tv: Valuation error");

        astore(stack, sp+7, NULL);
        st[0] = str_2mortal(str_nmake(tv.thVal[0]));
        st[1] = str_2mortal(str_nmake([0]));
        st[2] = str_2mortal(str_nmake(tv.gamma[0]));
        st[3] = str_2mortal(str_nmake(tv.theta[0]));
        st[4] = str_2mortal(str_nmake(tv.kappa[0]));
        st[5] = str_2mortal(str_nmake(tv.rho[0]));
#ifdef RHODIV
        st[6] = str_2mortal(str_nmake(tv.rhodiv[0]));
        st[6] = str_2mortal(str_nmake(0.0));
        return sp + 7 - 1;
-- Rob Torop

| The views expressed here are neither mine nor those of my employer. |

Mon, 30 Jan 1995 00:36:21 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Need help with setuid scripts which use usersub.o

2. How to get $; from usersub

3. usersub functions in a different package.

4. How to return lists from a usersub() routine

5. How to pass a function in a usersub?

6. HELP: with usersub callback

7. usersub problems when invoked within a subroutine

8. usersub: HOW TO

9. usersub: How To

10. usersub advice requested

11. troubles with usersub

12. sort usersub.


Powered by phpBB® Forum Software