Home » Extra libraries, Code snippets, applications etc. » C++ language problems and code snippets » Optimized memcmp for x86
Re: Optimized memcmp for x86 [message #14360 is a reply to message #14308] |
Sat, 23 February 2008 18:56 |
mr_ped
Messages: 825 Registered: November 2005 Location: Czech Republic - Praha
|
Experienced Contributor |
|
|
Yes, that's the problem.
In good old days of ZX Spectrum I was sure I can read beyond "len" and nothing will happen (except getting weird data).
But nowadays I don't know so much about different platforms and OS to be sure you can read aligned double word without causing some exception or crash of application.
I think x86 works usually with aligned memory allocation, so you basically can NOT allocate like 13 bytes only, but the "THINK" word is the crucial part of this sentence.
The C++ itself does not do any memory read checking, so it's up to OS.
So I think the testing application which will allocate memory by OS mem allocator directly would give us the reliable answer.
Than again if such OS allocators allow to allocate only for example 4kB chunks and not 13 bytes, I think it will never raise exception or crash and you may safely read beyond end of buffer.
[Updated on: Sat, 23 February 2008 18:56] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Thu May 23 16:30:05 CEST 2024
Total time taken to generate the page: 0.02193 seconds
|