Re: Searching in byte buffer



On Fri, 28 Oct 2005 10:35:57 -0400, "Bruce Roberts"
<dontsendtober@xxxxxxxxxxxxxxxxxxxx> wrote:

>
>"Jatin" <TripleDerby100-ng@xxxxxxxxx> wrote in message
>news:Yrh8f.8786$tV6.5427@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>>I want to search a byte buffer for certain pattern of bytes. It is similar
>>to searching for a substring within a string, however I want to perform
>>search on a byte buffer (array) for series of bytes. Also, it needs to be
>>a fast search, as search is performed on bytes retrieved from soundcard
>>buffer.

>I suspect that the Boyer-Moore algorithm might prove useful. While its
>always talked about in terms of textual searches there is no reason, AFAIK,
>that a variant couldn't be used for general buffer searches.

True - in fact there are a few wrinkles

A text search is not strictly speaking a byte search, because of those
confounded MBCS 'things', which is why it is always wise digging down
into the library to see whether ASCIIZ string routines are used or an
API ANSI comparison routine.

The other wrinkle is that Boyers-Moore is good for repeated search for
the same thing, but because it has considerably more 'setup' it might
not be quicker for non-repetitive searches.

.



Relevant Pages

  • Re: Discovering variable types...
    ... >- but I suppose MS expect us to use wrappers ... memory allocations for your variables from disk as well. ... >They most certainly are of fixed size, changing the size of a String ... >>me to keep buffer size and current postion right in the memory block. ...
    (comp.lang.pascal.delphi.misc)
  • Re: Secure C library
    ... I read much of the new "security TR", and gee, I don't know. ... the buffer from the buffer size. ... It is not hard to design a better form of buffer and string handling. ... but this is just one example of how thoughtful interface design can ...
    (comp.std.c)
  • Re: Secure C library
    ... >> string functions don't make much sense once you add bounds-checking ... >> designing an interface just for the purpose of reducing the frequency ... > make buffer size decisions more visible, ... Bstrlib is also very interoperable with char *'s, ...
    (comp.std.c)
  • Re: why I can not write to the file after initialize the MFC in a service program
    ... you check EVERY return from a call that can fail, ... Why do you need an intermedate buffer to write literal strings anyway? ... For example, if AfxWinInit fails, you copy a 45-character string into a ... So you are going to try to initialize MFC EACH TIME THROUGH THE LOOP? ...
    (microsoft.public.vc.mfc)
  • Re: Calling dll functions from vb.net with pointer returns!
    ... (ByRef pulLen As Integer, ByVal pszFilter As String, ByVal ulFlags As ... OUT PTCHAR Buffer, ... Address of a buffer to receive a set of NULL-terminated device instance ... pszFilter must specify the name of a device ...
    (microsoft.public.dotnet.languages.vb)