Menu

Please use "two dimensional" lists in NCO

Developers
2005-05-25
2013-10-17
  • Charlie Zender

    Charlie Zender - 2005-05-25

    Hi Henry,

    I hope all is well with you and that you remain unscathed by the mass
    hysteria associated with the sale of Manchester United to a Yank.

    I cleaned up most of of the memory usage in ncks.
    There is one remaining item that I would like you to finish.
    You introduced the lmt_all structure in ncks to support
    multi-slabbing. The memory associated with lmt_all was handled
    similar to the lmt structure usage at the time.

    Since then, I've changed the fundamental allocation and destruction
    methods for lmt structures to be much more "object oriented".
    If you read any of the arithmetic operators you will see how
    lmt structures are handled. It's what I call two dimension lists:
    **lmt points to a list of pointers to limit structures.
    By contrast, *lmt_all is a pointer to a single buffer which holds
    N lmt_all structures in contiguous memory (lmt used to be implemented
    this way, too). I find the current implementation ("one dimensional
    lists") very hard to memory manage, because single lmt_all structures
    are difficult to treat independently.

    I would like you to implement the "two dimensional list" treatment for
    lmt_all in ncks. The goal is for ncks to have two dimensional list(s)
    of lmt_all structures which are easily free()'d at the end.
    I've already added the nco_lmt_all_free() and nco_lmt_all_lst_free()
    routines (but do not call them). However the details of the lmt_all
    structure manipulation and associated routines are something you are
    more familiar with than me. Let me know if this request is unclear.

    Thanks,
    Charlie

     
    • Nobody/Anonymous

      Hi Charlie,
      Mr Glazer has yet to show his face an Man united. When he does, I'm sure the fans will give him an appropriate welcome.

      Have done th1D to 2D stuff. One  compile warning I couldn't get rid of in ncks.c

      nks.c (485)  warning: passing arg 5 of `nco_cpy_var_dfn_lmt' from incompatible pointer type

      Regards Henry

       
    • Charlie Zender

      Charlie Zender - 2005-05-26

      Hi Henry,

      OK, your 2D lmt_all structs are a good start.
      I fixed the warning by contifying the function prototype.
      But we're not done yet because I can't figure out how to free() them.
      I can free all the lmt structs (with nco_lmt_lst_free()) or all the
      lmt_all structs (with nco_lmt_all_lst_free()), but not both.
      In other words there is not a clean separation between lmt and lmt_all
      structures.

      I made some progress but I don't know how to free the whole list
      lmt_dmn list safely.
      So I need you to untangle these lists and/or modify
      nco_lmt_all_*_free() so that all the memory is easily free()d by the
      end of ncks.
      I modified ncks.c so that lmt_dmn[0] initialization is more
      complete so that it should be free()'able by nco_lmt_free().
      It is important, for the sake of modularity, that lmt_dmn be free()d
      by the nco_lmt_free() routines.
      I added some notes to ncks.c about lmt_all code blocks that should
      probably be subroutinized because they are too low level for the
      main.c file.
      I added a strdup() so there wouldn't be a dangling pointer to nm.
      lmt_dmn is a lmt_all ** yet element 0 is treated specially.
      This confuses me.
      I'm not sure that nbr_dmn_fl is the length of the list, i.e.,
      are there always nbr_dmn_fl lmt_all list members at the end of ncks?

      Please try to clean up the memory as much as possible, using valgrind
      to verify (see TODO nco525). We can iterate further as needed.

      Thanks,
      Charlie

       
    • Nobody/Anonymous

      Hi Charlie,
      Have added an new limit array to solve memory problems
      lmt_rgr[idx] ;

      Freeing seems to be working OK now

      Regards Henry

       
    • Charlie Zender

      Charlie Zender - 2005-05-30

      Hi Henry,

      Thanks, that got me to the next stage: nco_msa.c
      It needed about a half-dozen nco_free()'s.
      After sprinkling these about, I think ncks is now memory-pure.

      There's a tiny leak (3 bytes) in ncatted under certain
      conditions. I don't plan to pursue that one now.
      Besides that leak, I think all NCO operators
      except for ncap are memory pure.
      Purifying ncap is now TODO nco532.

      Charlie

       

Log in to post a comment.