- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Does anyone know how if ?copy has guarantees for overlapping source/target regions?
i.e. is it more memmove() than memcpy(), so that the direction of copying is factored in to prevent overruns ?
Newton
--------
i.e. is it more memmove() than memcpy(), so that the direction of copying is factored in to prevent overruns ?
Newton
--------
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - newton_particle
Does anyone know how if ?copy has guarantees for overlapping source/target regions?
i.e. is it more memmove() than memcpy(), so that the direction of copying is factored in to prevent overruns ?
i.e. is it more memmove() than memcpy(), so that the direction of copying is factored in to prevent overruns ?
Backwards copy is usually slow anyway (barring specially aligned cases) on Intel processors prior to Core i7, and AMD processors prior to Barcelona, so it's not safe to assume that an implementation of memmove() or equivalent is the most efficient one for your processor, unless you write/test it yourself. This may require fairly low level code, such as SSE intrinsics.
If you used ?COPY incorrectly, with overlapping data, it wouldn't necessarily be an over-run, but the source data would be over-written before use. memmove() likewise has no protection against over-run, should you exceed the target limits.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page