summaryrefslogtreecommitdiff
path: root/mq_cmd.c
diff options
context:
space:
mode:
authorFreeArtMan <dos21h@gmail.com>2017-03-14 23:20:43 +0000
committerFreeArtMan <dos21h@gmail.com>2017-03-14 23:20:43 +0000
commitad204ea75ef53fa9c183fb29845e2da33795089b (patch)
tree9933026ae73c1711367539441aac51cbdcf2aca4 /mq_cmd.c
parent85c7b6ed10cbeb3fbcb301dff6ab58e0398bde68 (diff)
downloadagni-ad204ea75ef53fa9c183fb29845e2da33795089b.tar.gz
agni-ad204ea75ef53fa9c183fb29845e2da33795089b.zip
Now request and response matching id
Diffstat (limited to 'mq_cmd.c')
-rw-r--r--mq_cmd.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/mq_cmd.c b/mq_cmd.c
index 5570ec3..93e7ea8 100644
--- a/mq_cmd.c
+++ b/mq_cmd.c
@@ -1,6 +1,6 @@
#include "mq_cmd.h"
-#define MQ_CMD_MSG_SIZE 8192
+#define MQ_CMD_MSG_SIZE 1024
//last string element should be string ;]
mq_cmd* mq_cmd_create(int id, char *cmd, size_t cmd_sz, char *param, size_t param_sz)
{
@@ -23,11 +23,12 @@ mq_cmd* mq_cmd_create(int id, char *cmd, size_t cmd_sz, char *param, size_t para
ENL();
return NULL;
}
- memset(ret,0, sizeof(mq_cmd));
+ //memset(ret, 0, sizeof(mq_cmd));
ret->id = id;
ret->sz = MQ_CMD_MSG_SIZE;
ret->buf = malloc(MQ_CMD_MSG_SIZE);
+ memset(ret->buf, 0, MQ_CMD_MSG_SIZE); //speed? who cares
if (ret->buf == NULL)
{
ENL();
@@ -47,13 +48,15 @@ mq_cmd* mq_cmd_creates(char *str, size_t sz, int id)
mq_cmd *ret = NULL;
//just naive belive everything is fine in string
- ret = malloc(sizeof(mq_cmd));
+ ret = malloc(sizeof(mq_cmd)); //can blow up
ret->buf = malloc(sz);
if (ret->buf == NULL)
{
PERM();
+ free(ret);
return NULL;
}
+ memset(ret->buf, 0, MQ_CMD_MSG_SIZE);
ret->sz = sz;
memcpy(ret->buf,str,sz);
ret->id = id;
@@ -185,7 +188,7 @@ int mq_cmd_param(mq_cmd *cmd, char **param, size_t *sz)
}
strt = i;
*param = cmd->buf+strt;
- *sz = cmd->sz - strt+1;
+ *sz = cmd->sz - strt+1;//BUG MUAHAHA
return 0;
}
@@ -218,8 +221,8 @@ void mq_cmd_free(mq_cmd *mq)
free(mq->buf);
mq->buf = NULL;
free(mq);
+ mq = NULL;
}
-
}