if (Msg->cm_fields[which] != NULL) {
free (Msg->cm_fields[which]);
}
+ if (length < 0) { // You can set the length to -1 to have CM_SetField measure it for you
+ length = strlen(buf);
+ }
Msg->cm_fields[which] = malloc(length + 1);
memcpy(Msg->cm_fields[which], buf, length);
Msg->cm_fields[which][length] = '\0';
Msg->cm_fields[which] = *buf;
*buf = NULL;
- Msg->cm_lengths[which] = length;
+ if (length < 0) { // You can set the length to -1 to have CM_SetField measure it for you
+ Msg->cm_lengths[which] = strlen(buf);
+ }
+ else {
+ Msg->cm_lengths[which] = length;
+ }
}