Gnutella Forums

Gnutella Forums (https://www.gnutellaforums.com/)
-   Mutella (Linux/Unix) (https://www.gnutellaforums.com/mutella-linux-unix/)
-   -   Some questions on Mutella 0.3.3 (https://www.gnutellaforums.com/mutella-linux-unix/8258-some-questions-mutella-0-3-3-a.html)

Moak August 21st, 2002 06:13 AM

Good luck with your new home, if you're becoming my neighbour call me for a beer. :)

Thx for the answers, I still need lots of time. Since my network
class grows with my server (no Gnutella thingie) and the server
takes all my time. I'll plan to use STL std::string with some tiny
addition yet like sstring::format() and sstring::operator const char*().

Btw when using std::string here's a port of format() member:

Code:

void vformat(const char *fmt, va_list ap)
{
    if(strstr(fmt, "%n")) {            //check against %n, which can be exploited by accident
        assert(0 && "sstring::format: Parachute for unsafe type %n");
        assign(fmt);                    //note: really nobody needs unsafe %n
        return;
    }
   
    std::vector<char> buffer;          //buffer for creating string
    size_t size = strlen(fmt)+16;      //some extra characters, string will grow

    while (1)
    {
        buffer.reserve(size);          //ensure we have that much space in the buffer
                                        //try to print into allocated space
        int n = vsnprintf(&buffer[0], buffer.capacity(), fmt, ap);
        if (n>-1 && n<buffer.capacity())
        {                              //allocated space was fine
            assign(&buffer[0]);        //store the formated string (unfortunately a copy)
            return;
        }
                                        //else try again with more space
        if (n>-1)                      //glibc 2.1
            size = n+1;                //precisely what is needed
        else                            //glibc 2.0 or MS-crt
            size = buffer.capacity()*2; //twice the old size
    }
}


Unregistered September 4th, 2002 08:00 AM

hm, I wonder where the random generator is initialized? grep srand finds nothing. Propably I'm using an old version?

maksik September 19th, 2002 10:08 AM

Quote:

Originally posted by Moak
Good luck with your new home, if you're becoming my neighbour call me for a beer. :)

Goood idea Moak! Once I get things right here I'd be looking for an occasion :-))

--Max


All times are GMT -7. The time now is 03:36 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 ©2011, Crawlability, Inc.

Copyright © 2020 Gnutella Forums.
All Rights Reserved.