summaryrefslogtreecommitdiff
path: root/mq_cmd.c
diff options
context:
space:
mode:
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;
}
-
}