]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Add a comment about a puzzling piece of code
authorFrederic Marchal <fmarchal@users.sourceforge.net>
Wed, 10 Dec 2014 20:57:56 +0000 (21:57 +0100)
committerFrederic Marchal <fmarchal@users.sourceforge.net>
Wed, 10 Dec 2014 20:57:56 +0000 (21:57 +0100)
The trick to store the same string only once is not clear and deserves a
little comment.

userinfo.c

index e9338616fba518efc36b1da31ca86d6454a04887..89be0ddbb552e766968861c4176c98c8ccaabc55 100644 (file)
@@ -111,9 +111,16 @@ struct userinfostruct *userinfo_create(const char *userid,const char *ip)
        }
        user->label=user->id; //assign a label to avoid a NULL pointer in case none is provided
        if (ip) {
+               /*
+                * IP address is not the same as the user's ID. A separate buffer
+                * must be allocated.
+                */
                user->id_is_ip=false;
                user->ip=StringBuffer_Store(UserStrings,ip);
        } else {
+               /*
+                * User's IP address share the same buffer as the user's ID.
+                */
                user->id_is_ip=true;
                user->ip=user->id;
        }