Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. proper use of ini-files

proper use of ini-files

Scheduled Pinned Locked Moved C / C++ / MFC
questionperformance
11 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Sebastian Blatt

    Hi, almost every one of my programs uses an ini-file. I have written a class that scans the file at program start and stores all variables in a global dynamically allocated struct. Because this takes some memory when the program gets larger, I was wondering if scanning the file for a particular entry when it is actually needed wouldn't be the better alternative. What is the 'proper' way to use ini-files and why? -Sebastian

    T Offline
    T Offline
    Tomasz Sowinski
    wrote on last edited by
    #2

    While the discussion on reading ini at startup versus on-demand would be interesting, I think you should ask yourself if it's worth the trouble. How much memory are you using for this global struct? Tomasz Sowinski -- http://www.shooltz.com

    S 1 Reply Last reply
    0
    • T Tomasz Sowinski

      While the discussion on reading ini at startup versus on-demand would be interesting, I think you should ask yourself if it's worth the trouble. How much memory are you using for this global struct? Tomasz Sowinski -- http://www.shooltz.com

      S Offline
      S Offline
      Sebastian Blatt
      wrote on last edited by
      #3

      Hi, its not very much for a smaller program, but I was wondering if I should really store every minor option like background colors, switches for controls or windows the whole time the program is running. Thanks for your time. -Sebastian

      T 1 Reply Last reply
      0
      • S Sebastian Blatt

        Hi, its not very much for a smaller program, but I was wondering if I should really store every minor option like background colors, switches for controls or windows the whole time the program is running. Thanks for your time. -Sebastian

        T Offline
        T Offline
        Tomasz Sowinski
        wrote on last edited by
        #4

        Assume that it's biggest program you're ever going to write. Multiply the struct size by 4. How much memory are you going to allocate? Tomasz Sowinski -- http://www.shooltz.com

        S 1 Reply Last reply
        0
        • T Tomasz Sowinski

          Assume that it's biggest program you're ever going to write. Multiply the struct size by 4. How much memory are you going to allocate? Tomasz Sowinski -- http://www.shooltz.com

          S Offline
          S Offline
          Sebastian Blatt
          wrote on last edited by
          #5

          OK, you're right, it won't use up all my RAM. But is it really good programming practice to have all these unused variables lying around all the time? -Sebastian

          T 1 Reply Last reply
          0
          • S Sebastian Blatt

            OK, you're right, it won't use up all my RAM. But is it really good programming practice to have all these unused variables lying around all the time? -Sebastian

            T Offline
            T Offline
            Tomasz Sowinski
            wrote on last edited by
            #6

            Good programming practice is to spend your development time on issues that really matter. I don't believe that loading ini settings at startup can hurt you or your performance. If it works for you, leave it, unless you have nothing else to do (in this case, it's better idea to go for some beer). Tomasz Sowinski -- http://www.shooltz.com

            1 Reply Last reply
            0
            • S Sebastian Blatt

              Hi, almost every one of my programs uses an ini-file. I have written a class that scans the file at program start and stores all variables in a global dynamically allocated struct. Because this takes some memory when the program gets larger, I was wondering if scanning the file for a particular entry when it is actually needed wouldn't be the better alternative. What is the 'proper' way to use ini-files and why? -Sebastian

              R Offline
              R Offline
              realJSOP
              wrote on last edited by
              #7

              It's simply a matter of what is prudent within the context of the program's architecture. I think almost all of my programs do it that way (loading the ini data into a struct or object). There is no "proper" way to do it really beyond obeying the laws of C++ physics. :-)

              R 1 Reply Last reply
              0
              • R realJSOP

                It's simply a matter of what is prudent within the context of the program's architecture. I think almost all of my programs do it that way (loading the ini data into a struct or object). There is no "proper" way to do it really beyond obeying the laws of C++ physics. :-)

                R Offline
                R Offline
                Ray Kinsella
                wrote on last edited by
                #8

                I though ini files where long since dead ... I put everything in the registry these days.... Regards Ray "Je Suis Mort De Rire"

                T R 2 Replies Last reply
                0
                • R Ray Kinsella

                  I though ini files where long since dead ... I put everything in the registry these days.... Regards Ray "Je Suis Mort De Rire"

                  T Offline
                  T Offline
                  Tomasz Sowinski
                  wrote on last edited by
                  #9

                  Ray, You've just started a flamewar... Cheers, Tomasz Sowinski -- http://www.shooltz.com

                  R 1 Reply Last reply
                  0
                  • R Ray Kinsella

                    I though ini files where long since dead ... I put everything in the registry these days.... Regards Ray "Je Suis Mort De Rire"

                    R Offline
                    R Offline
                    realJSOP
                    wrote on last edited by
                    #10

                    I don't use the registry unless it makes sense to do so. The more data tha's contained in the registry, the longer it takes Windows to load. COM forces registry use, so if a program uses COM, there's no reason not to contribute to the registry bloat, but for simple programs, why bother? INI files are alive and well - long live INI files. :-)

                    1 Reply Last reply
                    0
                    • T Tomasz Sowinski

                      Ray, You've just started a flamewar... Cheers, Tomasz Sowinski -- http://www.shooltz.com

                      R Offline
                      R Offline
                      realJSOP
                      wrote on last edited by
                      #11

                      Oh sure, make me out to be the bad guy... YOU BASTARD! :-) I KEEL YOU! I KEEL YOU ALL!!!! :laugh:

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups