× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.




Hadn't thought of this!  So are you thinking I should read it into something
that can hold it (i.e. User space) or do some pointer arithmetic on a string
that has a base pointer?  I am thinking it would probably be faster to do
the pointer arithmetic.

I'd use the TS_malloc() API to allocate one piece of memory for the whole thing. I'd use TS_malloc() instead of %alloc() because it allows you to create an allocatation that exceeds 16mb. I don't know if that's needed or not.

The next problem will be doing the replaces. It's relatively easy to search a big area of memory, but much harder to replace the data efficiently.

The problem is "moving" all of the data that comes after the replacement when the original length and the new length aren't the same.

For example, if you have "Press the &lt;enter&gt; key" and you make it say "Press the <enter> key" how would you do it? You search for &lt;. When you find it, you replace it with "<"... but since "<" is one character and "&lt;" is 4 characters, you'll have 3 extra spaces after the <. How do you get rid of those spaces? You copy the text"enter&gt; key" 3 spaces to the left... that eliminates the extra space.

Not a big deal with a string that short, it'll only take a second.

However, if you have megabytes of data, and you have to copy it over a few spaces with every single find/replace operationg that you do, that'll add a lot of processing time.

You might be able to whip up a nice search and replace function using
memcpy and memcmp.

Also memchr(). You use memchr() to find the initial character in memory. Then you use memcmp() to see if it matches the whole string. Then you use memcpy() (or probbaly memmove()) to do the replace.

In my experiencing, using memchr() followed by memcmp() is much faster than using memcmp() on every byte, or checking each byte individually using a based field. YMMV, of course.

Anyway, Aaron, I thought you didn't do RPG anymore? Didn't you say you became a full time Java guy?

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.