void pn_dispatcher_free(pn_dispatcher_t *disp) { if (disp) { pn_buffer_free(disp->input); pn_data_free(disp->args); pn_data_free(disp->output_args); pn_buffer_free(disp->frame); free(disp->output); pn_free(disp->scratch); free(disp); } }
void process_flow(ldp_connection_t *conn, pn_event_t *event) { fprintf(stderr, "flow event %s\n", pn_event_type_name(pn_event_type(event))); pn_link_t *sender = pn_event_link(event); pn_message_t *message = pn_message(); pn_message_set_address(message, "amqp://foo/bar"); pn_data_t *body = pn_message_body(message); char *msgtext = "hello world!"; pn_data_put_string(body, pn_bytes(strlen(msgtext), msgtext)); pn_buffer_t *buffer = pn_buffer(1000); char *encoded = pn_buffer_bytes(buffer).start; size_t size = pn_buffer_capacity(buffer); int err = pn_message_encode(message, encoded, &size); if (err) { fprintf(stderr, "trouble encoding message\n"); } else { char tag[8]; static uint64_t next_tag; *((uint64_t*)tag) = ++next_tag; pn_delivery_t *d = pn_delivery(sender, pn_dtag(tag, 8)); pn_link_send(sender, encoded, size); pn_link_advance(sender); } pn_buffer_free(buffer); pn_message_free(message); }
void pn_sasl_free(pn_transport_t *transport) { if (transport) { pni_sasl_t *sasl = transport->sasl; if (sasl) { free(sasl->selected_mechanism); free(sasl->included_mechanisms); free(sasl->password); free(sasl->config_name); free(sasl->config_dir); free(sasl->external_auth); // CYRUS_SASL if (sasl->impl_context) { pni_sasl_impl_free(transport); } pn_buffer_free(sasl->decoded_buffer); pn_buffer_free(sasl->encoded_buffer); free(sasl); } } }
int buffer(int argc, char **argv) { pn_buffer_t *buf = pn_buffer(16); pn_buffer_append(buf, "abcd", 4); pn_buffer_print(buf); printf("\n"); pn_buffer_prepend(buf, "012", 3); pn_buffer_print(buf); printf("\n"); pn_buffer_prepend(buf, "z", 1); pn_buffer_print(buf); printf("\n"); pn_buffer_append(buf, "efg", 3); pn_buffer_print(buf); printf("\n"); pn_buffer_append(buf, "hijklm", 6); pn_buffer_print(buf); printf("\n"); pn_buffer_defrag(buf); pn_buffer_print(buf); printf("\n"); pn_buffer_trim(buf, 1, 1); pn_buffer_print(buf); printf("\n"); pn_buffer_trim(buf, 4, 0); pn_buffer_print(buf); printf("\n"); pn_buffer_clear(buf); pn_buffer_print(buf); printf("\n"); pn_buffer_free(buf); pn_data_t *data = pn_data(16); int err = pn_data_fill(data, "Ds[iSi]", "desc", 1, "two", 3); if (err) { printf("%s\n", pn_code(err)); } pn_data_print(data); printf("\n"); pn_bytes_t str; err = pn_data_scan(data, "D.[.S.]", &str); if (err) { printf("%s\n", pn_code(err)); } else { printf("%.*s\n", (int) str.size, str.start); } pn_data_clear(data); pn_data_fill(data, "DL[SIonn?DL[S]?DL[S]nnI]", ATTACH, "asdf", 1, true, true, SOURCE, "queue", true, TARGET, "queue", 0); pn_data_print(data); printf("\n"); pn_data_free(data); return 0; }
void pni_entry_free(pni_entry_t *entry) { if (!entry) return; pni_stream_t *stream = entry->stream; pni_store_t *store = stream->store; LL_REMOVE(stream, stream, entry); LL_REMOVE(store, store, entry); entry->free = true; pn_buffer_free(entry->bytes); entry->bytes = NULL; pn_decref(entry); store->size--; }
void pn_message_free(pn_message_t *msg) { if (msg) { pn_buffer_free(msg->user_id); pn_buffer_free(msg->address); pn_buffer_free(msg->subject); pn_buffer_free(msg->reply_to); pn_buffer_free(msg->content_type); pn_buffer_free(msg->content_encoding); pn_buffer_free(msg->group_id); pn_buffer_free(msg->reply_to_group_id); pn_data_free(msg->data); pn_data_free(msg->body); free(msg); } }