Re: Two Questions about "strlen", "strcat" and "strcpy"

From: jacob navia (jacob_at_jacob.remcomp.fr)
Date: 08/30/04


Date: Mon, 30 Aug 2004 15:23:57 +0200
To: Paul Hsieh <qed@pobox.com>

Paul Hsieh wrote:
> People who have seen me post here before already know the punchline.
> I've written a string library that does precisely this sort of thing
> (as well as all sorts of other things related to speed, safety,
> functionality and maintainability). You can learn more by visiting
> the second link below.
>
> --
> Paul Hsieh
> http://www.pobox.com/~qed/
> http://bstring.sf.net/

The approach you take is the good one. Length delimited strings!

The string library lcc-win32 proposes is the same idea but with some
syntatic sugar around it:
1) You can index Strings like char *:
        String S1 = "abc";
        S1[1] // yields 'b'
        S1[1] = 'X' // String is now "aXc"
        
2) You can assign them to local variables in the normal way as shown above

3) All strings are garbage collected. No more "free" problems.

4) Function names are cloned from the C library:
        Strcpy
        Strcat
        etc

Easy to use, easy to learn.

Lcc-win32:
http://www.cs.virginia.edu/~lcc-win32

jacob



Relevant Pages

  • Re: Solution for sorting an array alpha-numerically
    ... strings up into groups and sorting the groups seperately, ... > so that numeric and alphabetic data sort as seperate groups. ... To the same project as the web page, add the class AlphaNumCompare() ...
    (microsoft.public.dotnet.general)
  • Re: a question for sorting keys in Map
    ... I have a Map, actually a TreeMap, which will automatically sort the keys ... You can write your own Comparator object which implements the Compare ... strings so that X10 comes after X2 instead of before it. ... Unix ls command sort file names the way you want your strings to sort. ...
    (comp.lang.java.programmer)
  • Re: Detailed explanation of how a QuickSort Works
    ... Static player1 As Object ... But actually loading the data from the mp3 file from the disk and analyzing that data and decompressing it and arranging to stream it in a way that causes the song to be played through your speakers is a fairly complicated task, and almost all programmers will happily leave all that "knowledge" safely in the hands of the Player1 object and will treat it merely as a "black box" in the way I mentioned above. ... when sorting a large number of strings you will find it very much quicker to modify your sort routine so that it sorts "Long pointers" to the strings rather than sorting the string data itself. ...
    (microsoft.public.vb.general.discussion)
  • Re: fast stable sort
    ... Can you post C code for a stable in place mergesort function? ... How do you load a herd of strings into your ... diddles the pointers, not the strings. ... In this case the requirement is to sort the pointers in place ...
    (comp.programming)
  • One more "strlen" - was: Note to Chuck Crayne
    ... optimize strlen to shave one cycle off it, and you distribute your library to 1000 users, and they each write a program that uses strlen 1000 times, and distribute it to 1000 end-users, and they each run it ... We would of course only do strlen once per string, so we have to imagine we've got a lot of strings being thrown at us. ... When I click on the little hieroglyph to "sort by thread" instead of "sort by date", it takes - by wall clock - approximately a minute and fifteen seconds to complete. ... A better approach would be to keep a running index table for every column the user can sort by and every index table should be updated every time Thunderbird recieves an email/post...this way, the click on the glyph merrly selects which index table to use when picking what message headings to show in the window -- no need to run no freak'n algo. ...
    (alt.lang.asm)