From acf0b78c5203a65923a07e0798f4a30291a804e8 Mon Sep 17 00:00:00 2001 From: Frederic Marchal Date: Wed, 10 Dec 2014 21:57:56 +0100 Subject: [PATCH] Add a comment about a puzzling piece of code The trick to store the same string only once is not clear and deserves a little comment. --- userinfo.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/userinfo.c b/userinfo.c index e933861..89be0dd 100644 --- a/userinfo.c +++ b/userinfo.c @@ -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; } -- 2.47.2