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. is there platform-independent FillMemory function in C/C++!?

is there platform-independent FillMemory function in C/C++!?

Scheduled Pinned Locked Moved C / C++ / MFC
c++performancequestion
7 Posts 3 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.
  • C Offline
    C Offline
    clayman87
    wrote on last edited by
    #1

    Hi! I'm looking for some platform-independent C/C++ function which would be to pre-fill a large memory area with some value, just like FillMemory in win32 does. Does such a function exist, or do I have to make my own in assembly?

    J R 2 Replies Last reply
    0
    • C clayman87

      Hi! I'm looking for some platform-independent C/C++ function which would be to pre-fill a large memory area with some value, just like FillMemory in win32 does. Does such a function exist, or do I have to make my own in assembly?

      J Offline
      J Offline
      Joaquin M Lopez Munoz
      wrote on last edited by
      #2

      memset, in <string.h>. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo Want a Boost forum in Code Project? Vote here[^]!

      1 Reply Last reply
      0
      • C clayman87

        Hi! I'm looking for some platform-independent C/C++ function which would be to pre-fill a large memory area with some value, just like FillMemory in win32 does. Does such a function exist, or do I have to make my own in assembly?

        R Offline
        R Offline
        Rick York
        wrote on last edited by
        #3

        Have you looked at memset ? __________________________________________ a two cent stamp short of going postal.

        C 2 Replies Last reply
        0
        • R Rick York

          Have you looked at memset ? __________________________________________ a two cent stamp short of going postal.

          C Offline
          C Offline
          clayman87
          wrote on last edited by
          #4

          Is it elegant to use 'memset' in a full C++ environment?

          J 1 Reply Last reply
          0
          • R Rick York

            Have you looked at memset ? __________________________________________ a two cent stamp short of going postal.

            C Offline
            C Offline
            clayman87
            wrote on last edited by
            #5

            and, of course, is there any way to put not bytes but ints (4bytes) after each other? cause memset seems suitable only for single bytes...

            J 1 Reply Last reply
            0
            • C clayman87

              Is it elegant to use 'memset' in a full C++ environment?

              J Offline
              J Offline
              Joaquin M Lopez Munoz
              wrote on last edited by
              #6

              Is it elegant to use 'memset' in a full C++ environment? It is all the rage in C++ parties lately :) Seriously now, its usage is just fine, and, unlike FillMemory, it is platform-independent, which is what you were looking for. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo Want a Boost forum in Code Project? Vote here[^]!

              1 Reply Last reply
              0
              • C clayman87

                and, of course, is there any way to put not bytes but ints (4bytes) after each other? cause memset seems suitable only for single bytes...

                J Offline
                J Offline
                Joaquin M Lopez Munoz
                wrote on last edited by
                #7

                There is no low-level function to do this that I know of. You'd have to resort to a manual loop or some STL algorithm like std::fill. The difference is that memset is probably optimized for the particular HW targeted by the compiler, and so much faster. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo Want a Boost forum in Code Project? Vote here[^]!

                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