diff options
| author | Garrett D'Amore <garrett@damore.org> | 2025-01-01 17:06:39 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2025-01-01 17:06:39 -0800 |
| commit | f7bf24f429cbc488b861ab1b1e4cf1983af56295 (patch) | |
| tree | 2196361a906bd5db1148c0e177d69854a99b7b58 /include | |
| parent | ee5c8437f8c2a811c0eaef9b00c149b93c095391 (diff) | |
| download | nng-f7bf24f429cbc488b861ab1b1e4cf1983af56295.tar.gz nng-f7bf24f429cbc488b861ab1b1e4cf1983af56295.tar.bz2 nng-f7bf24f429cbc488b861ab1b1e4cf1983af56295.zip | |
api: Remove the NNG_FLAG_ALLOC
This flag failed to provide real zero copy that it was intended for,
and it also involved extra allocations. Further, the API for it was
brittle and error prone.
Modern code should just work directly with nng_msg structures.
Diffstat (limited to 'include')
| -rw-r--r-- | include/nng/nng.h | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/include/nng/nng.h b/include/nng/nng.h index a3dafb7a..664da2d5 100644 --- a/include/nng/nng.h +++ b/include/nng/nng.h @@ -387,19 +387,12 @@ NNG_DECL const char *nng_strerror(int); // this function may (will!) return before any receiver has actually // received the data. The return value will be zero to indicate that the // socket has accepted the entire data for send, or an errno to indicate -// failure. The flags may include NNG_FLAG_NONBLOCK or NNG_FLAG_ALLOC. -// If the flag includes NNG_FLAG_ALLOC, then the function will call -// nng_free() on the supplied pointer & size on success. (If the call -// fails then the memory is not freed.) +// failure. The flags may include NNG_FLAG_NONBLOCK. NNG_DECL int nng_send(nng_socket, void *, size_t, int); // nng_recv receives message data into the socket, up to the supplied size. // The actual size of the message data will be written to the value pointed -// to by size. The flags may include NNG_FLAG_NONBLOCK and NNG_FLAG_ALLOC. -// If NNG_FLAG_ALLOC is supplied then the library will allocate memory for -// the caller. In that case the pointer to the allocated will be stored -// instead of the data itself. The caller is responsible for freeing the -// associated memory with nng_free(). +// to by size. The flags may include NNG_FLAG_NONBLOCK. NNG_DECL int nng_recv(nng_socket, void *, size_t *, int); // nng_sendmsg is like nng_send, but offers up a message structure, which @@ -488,10 +481,9 @@ NNG_DECL int nng_ctx_set_ms(nng_ctx, const char *, nng_duration); // specific API. NNG_DECL void *nng_alloc(size_t); -// nng_free is used to free memory allocated with nng_alloc, which includes -// memory allocated by nng_recv() when the NNG_FLAG_ALLOC message is supplied. -// As the application is required to keep track of the size of memory, this -// is probably less convenient for general uses than the C library malloc and +// nng_free is used to free memory allocated with nng_alloc. As the +// application is required to keep track of the size of memory, this is +// probably less convenient for general uses than the C library malloc and // calloc. NNG_DECL void nng_free(void *, size_t); @@ -711,7 +703,6 @@ NNG_DECL nng_dialer nng_pipe_dialer(nng_pipe); NNG_DECL nng_listener nng_pipe_listener(nng_pipe); // Flags. -#define NNG_FLAG_ALLOC 1u // Recv to allocate receive buffer #define NNG_FLAG_NONBLOCK 2u // Non-blocking operations // Options. |
