diff --git a/include/psyc.h b/include/psyc.h index 860d7d4..5b6e3ec 100644 --- a/include/psyc.h +++ b/include/psyc.h @@ -124,8 +124,8 @@ typedef struct typedef struct { - size_t length; - PSYC_Modifier *ptr; + size_t lines; + PSYC_Modifier **modifiers; } PSYC_ModifierArray; /* intermediate struct for a PSYC packet */ diff --git a/src/psyc.c b/src/psyc.c index 6aec5e1..547e1d9 100644 --- a/src/psyc.c +++ b/src/psyc.c @@ -71,12 +71,12 @@ inline PSYC_Packet PSYC_newPacket(PSYC_ModifierArray *routing, } // calculate routing header length - for (i = 0; i < routing->length; i++) - p.routingLength += PSYC_getModifierLength(&routing->ptr[i]); + for (i = 0; i < routing->lines; i++) + p.routingLength += PSYC_getModifierLength(routing->modifiers[i]); // calculate entity header length - for (i = 0; i < entity->length; i++) - p.contentLength += PSYC_getModifierLength(&routing->ptr[i]); + for (i = 0; i < entity->lines; i++) + p.contentLength += PSYC_getModifierLength(routing->modifiers[i]); // add length of method, data & delimiter p.contentLength += method->length + 1 + data->length; // method \n data @@ -95,8 +95,8 @@ inline PSYC_Packet PSYC_newPacket2(PSYC_Modifier **routing, size_t routinglen, const char *data, size_t datalen, PSYC_PacketFlag flag) { - PSYC_ModifierArray r = {routinglen, *routing}; - PSYC_ModifierArray e = {entitylen, *entity}; + PSYC_ModifierArray r = {routinglen, routing}; + PSYC_ModifierArray e = {entitylen, entity}; PSYC_String m = {methodlen, method}; PSYC_String d = {datalen, data}; diff --git a/src/render.c b/src/render.c index bcf9d7f..44234bb 100644 --- a/src/render.c +++ b/src/render.c @@ -27,16 +27,16 @@ PSYC_RenderRC PSYC_render(PSYC_Packet *packet, char *buffer, size_t buflen) if (packet->length > buflen) return PSYC_RENDER_ERROR; - for (i = 0; i < packet->routing.length; i++) - cur += PSYC_renderModifier(&packet->routing.ptr[i], buffer + cur); + for (i = 0; i < packet->routing.lines; i++) + cur += PSYC_renderModifier(packet->routing.modifiers[i], buffer + cur); if (packet->flag == PSYC_PACKET_NEED_LENGTH) cur += sprintf(buffer + cur, "%ld", packet->contentLength); memcpy(buffer + cur++, "\n", 1); - for (i = 0; i < packet->entity.length; i++) - cur += PSYC_renderModifier(&packet->entity.ptr[i], buffer + cur); + for (i = 0; i < packet->entity.lines; i++) + cur += PSYC_renderModifier(packet->entity.modifiers[i], buffer + cur); memcpy(buffer + cur, PSYC_C2ARG(PSYC_PACKET_DELIMITER));