pnoltes commented on a change in pull request #172: Refactor TcpAdmin and add interfacing for VectorIoSerialisation URL: https://github.com/apache/celix/pull/172#discussion_r400372469
########## File path: bundles/pubsub/pubsub_protocol_wire_v1/src/pubsub_wire_protocol_impl.c ########## @@ -65,19 +65,49 @@ celix_status_t pubsubProtocol_destroy(pubsub_protocol_wire_v1_t* protocol) { return status; } +celix_status_t pubsubProtocol_getHeaderSize(void* handle, size_t *length) { + *length = sizeof(int) * 5 + sizeof(short) * 2; // header + sync + version = 24 + + return CELIX_SUCCESS; +} + +celix_status_t pubsubProtocol_getHeaderBufferSize(void* handle, size_t *length) { + return pubsubProtocol_getHeaderSize(handle, length); +} + +celix_status_t pubsubProtocol_getSyncHeaderSize(void* handle, size_t *length) { + *length = sizeof(int); + return CELIX_SUCCESS; +} + celix_status_t pubsubProtocol_getSyncHeader(void* handle, void *syncHeader) { - for (int i = 0; i < 5; ++i) { - ((char *) syncHeader)[i] = '\0'; - } writeInt(syncHeader, 0, PROTOCOL_WIRE_SYNC); - return CELIX_SUCCESS; } +celix_status_t pubsubProtocol_isMessageSegmentationSupported(void* handle, bool *isSupported) { + *isSupported = false; + return CELIX_SUCCESS; +} celix_status_t pubsubProtocol_encodeHeader(void *handle, pubsub_protocol_message_t *message, void **outBuffer, size_t *outLength) { celix_status_t status = CELIX_SUCCESS; + // Get HeaderSize + size_t headerSize = 0; + pubsubProtocol_getHeaderSize(handle, &headerSize); - *outBuffer = calloc(1, 24); + if (*outBuffer == NULL) { + *outBuffer = calloc(1, headerSize); Review comment: update to malloc, combine realloc and calloc make no sense ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services