code comments;1 CKTfndDev

fred
2009-06-18
2013-06-12
  • fred
    fred
    2009-06-18

    just some comments   re as i'm trying to understand the code...

    cktfinddev.c 
    CKTfndDev(CKTcircuit *Ckt, in
    ...
       if (here->GENname == name)

    the ngspice is obviously working, but those lines of code are nevertheless perplexing!

    instead of using if(strcmp( here->GENname,name)==0)
    I think it is weak form and dangerous.

    Other Comment: By god they used void * in those ancient times, makes for horrible code reading!!!

    (i'm persisting with it, because i have a specific use for driving spice from another program, part of a
    simulation environment)

     
    • Holger Vogt
      Holger Vogt
      2009-06-28

      Fred,

      the code checks the pointers to two strings for equality, not the strings themselves. It is done since the old spice3f4 times. Maybe there is a good reason to do so, maybe not.

      Regards

      Holger

       
      • fred
        fred
        2009-06-29

        Thanks for your reply.

        On further looking,  the
        ft_curckt = NULL;  /* The default active circuit. */
        contains the INPtables symbol tales, so all strings are contained in these hash tables,

        so if you need to search for a node or something, the string is first looked up in
        the INPtables, and if it exists, using the  returned string is used to apply to functions like
        CKTfndDev, so knowing this, comparing just the pointers makes sense!

        well I think i'm understanding the frontend coding of ngspice anyway.

        But I haven't had any luck getting it to work as a server in windoz, so diving in and seeing
        what the problem is, maybe changing some code.

        Hehe,actually whilst tracing thru code i actually changed quite a few code where theres void pointers
        to data types, and fixed prototyes,  I  did this just so I could read and properly debug the code and view
        data structures, make  sense of stack traces etc etc, i just so hate void pointers.......
        I don't  know what the feeling is of people who are invested in using/maintaining ngspice, some people
        prefer to keep the status qo,   others like me prefer to see advancing the engineering of software,
        so whilst i did changes so far just to improve my understanding, perhaps it could get updated to the code?

        Also discovered gnucap/ACS, so looking at ongoing using this instead, but I suspect it might be useful to compare notes/results with ngspice, so since i invested some time in it already, i'm persisting to make it work in the short term for my purpose.

         
  • Holger Vogt
    Holger Vogt
    2009-09-12

    Fred,

    I agree with you that void pointers are obsolete.

    Maybe that you will share your code changes with us?

    You might just send the files changed.

    Regards

    Holger