add .gitignore
[remotetop.git] / sendtop.c
index 4a48662..9b41b22 100644 (file)
--- a/sendtop.c
+++ b/sendtop.c
@@ -90,6 +90,10 @@ getmeminfo(TCMsgTop *m) {
 
 #define MEMBUFSIZE 256
 
+/*
+ * if str mathes by pattern returns poineter to begin of value
+ * and NULL in opposite case
+ */
 static char*
 cmpPattern( char *str, char *pattern ) {
        while( *str != '\0' && *str == *pattern ) {
@@ -165,17 +169,17 @@ fillMsgTop(TCMsgTop *m) {
 static int
 sendTop(Msg *msg) {
        TCMsg *pmsg;
+       int msglen = TCMSGHDRSZ + sizeof(TCMsgTop);
 
        if ( !msg->msg ) {
-               int msglen = TCMSGHDRSZ + sizeof(TCMsgTop);
                pmsg = (TCMsg*)tmalloc(msglen);
-               pmsg->len = msglen;
-               pmsg->type=TOPMSGTYPE;
                msg->msg = pmsg;
        } else {
                pmsg = msg->msg;
        }
 
+       pmsg->len = msglen;
+       pmsg->type=TOPMSGTYPE;
        fillMsgTop( (TCMsgTop*)(pmsg->data) );
 
        return TC_sendMsg(msg);