Say "finalize" instead of "destroy" where appropriate
- _make() returns a struct directly - _init() initializes over a pointer - _free() deinitializes over a pointer - _new() is like _init() but also allocates - _destroy() is like _free() but also deallocates Finalization is a matching concept in garbage-collected languages.
This commit is contained in:
parent
83363e6383
commit
1d638c9170
|
@ -148,7 +148,7 @@ struct fcgi_muxer
|
||||||
(struct fcgi_request *, const void *data, size_t len);
|
(struct fcgi_request *, const void *data, size_t len);
|
||||||
|
|
||||||
/// Destroy the handler's data stored in the request object
|
/// Destroy the handler's data stored in the request object
|
||||||
void (*request_destroy_cb) (struct fcgi_request *);
|
void (*request_finalize_cb) (struct fcgi_request *);
|
||||||
|
|
||||||
/// Requests assigned to request IDs (may not be FCGI_NULL_REQUEST_ID)
|
/// Requests assigned to request IDs (may not be FCGI_NULL_REQUEST_ID)
|
||||||
struct fcgi_request *requests[1 << 8];
|
struct fcgi_request *requests[1 << 8];
|
||||||
|
@ -207,7 +207,7 @@ static void
|
||||||
fcgi_request_destroy (struct fcgi_request *self)
|
fcgi_request_destroy (struct fcgi_request *self)
|
||||||
{
|
{
|
||||||
// TODO: consider the case where it hasn't been started yet
|
// TODO: consider the case where it hasn't been started yet
|
||||||
self->muxer->request_destroy_cb (self);
|
self->muxer->request_finalize_cb (self);
|
||||||
|
|
||||||
str_map_free (&self->headers);
|
str_map_free (&self->headers);
|
||||||
fcgi_nv_parser_free (&self->hdr_parser);
|
fcgi_nv_parser_free (&self->hdr_parser);
|
||||||
|
@ -1538,7 +1538,7 @@ struct request_handler
|
||||||
bool (*push_cb) (struct request *request, const void *data, size_t len);
|
bool (*push_cb) (struct request *request, const void *data, size_t len);
|
||||||
|
|
||||||
/// Destroy the handler's data stored in the request object
|
/// Destroy the handler's data stored in the request object
|
||||||
void (*destroy_cb) (struct request *request);
|
void (*finalize_cb) (struct request *request);
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1551,7 +1551,7 @@ static void
|
||||||
request_free (struct request *self)
|
request_free (struct request *self)
|
||||||
{
|
{
|
||||||
if (self->handler)
|
if (self->handler)
|
||||||
self->handler->destroy_cb (self);
|
self->handler->finalize_cb (self);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This function is only intended to be run from asynchronous event handlers
|
/// This function is only intended to be run from asynchronous event handlers
|
||||||
|
@ -1651,7 +1651,7 @@ request_handler_json_rpc_push
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
request_handler_json_rpc_destroy (struct request *request)
|
request_handler_json_rpc_finalize (struct request *request)
|
||||||
{
|
{
|
||||||
struct str *buf = request->handler_data;
|
struct str *buf = request->handler_data;
|
||||||
str_free (buf);
|
str_free (buf);
|
||||||
|
@ -1664,7 +1664,7 @@ struct request_handler g_request_handler_json_rpc =
|
||||||
{
|
{
|
||||||
.try_handle = request_handler_json_rpc_try_handle,
|
.try_handle = request_handler_json_rpc_try_handle,
|
||||||
.push_cb = request_handler_json_rpc_push,
|
.push_cb = request_handler_json_rpc_push,
|
||||||
.destroy_cb = request_handler_json_rpc_destroy,
|
.finalize_cb = request_handler_json_rpc_finalize,
|
||||||
};
|
};
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -1820,7 +1820,7 @@ request_handler_static_push
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
request_handler_static_destroy (struct request *request)
|
request_handler_static_finalize (struct request *request)
|
||||||
{
|
{
|
||||||
(void) request;
|
(void) request;
|
||||||
// Nothing to dispose of this far
|
// Nothing to dispose of this far
|
||||||
|
@ -1830,7 +1830,7 @@ struct request_handler g_request_handler_static =
|
||||||
{
|
{
|
||||||
.try_handle = request_handler_static_try_handle,
|
.try_handle = request_handler_static_try_handle,
|
||||||
.push_cb = request_handler_static_push,
|
.push_cb = request_handler_static_push,
|
||||||
.destroy_cb = request_handler_static_destroy,
|
.finalize_cb = request_handler_static_finalize,
|
||||||
};
|
};
|
||||||
|
|
||||||
// --- Client communication handlers -------------------------------------------
|
// --- Client communication handlers -------------------------------------------
|
||||||
|
@ -2047,7 +2047,7 @@ client_fcgi_request_push
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
client_fcgi_request_destroy (struct fcgi_request *req)
|
client_fcgi_request_finalize (struct fcgi_request *req)
|
||||||
{
|
{
|
||||||
struct client_fcgi_request *request = req->handler_data;
|
struct client_fcgi_request *request = req->handler_data;
|
||||||
request_free (&request->request);
|
request_free (&request->request);
|
||||||
|
@ -2118,7 +2118,7 @@ client_fcgi_create (EV_P_ int sock_fd)
|
||||||
self->muxer.close_cb = client_fcgi_close_cb;
|
self->muxer.close_cb = client_fcgi_close_cb;
|
||||||
self->muxer.request_start_cb = client_fcgi_request_start;
|
self->muxer.request_start_cb = client_fcgi_request_start;
|
||||||
self->muxer.request_push_cb = client_fcgi_request_push;
|
self->muxer.request_push_cb = client_fcgi_request_push;
|
||||||
self->muxer.request_destroy_cb = client_fcgi_request_destroy;
|
self->muxer.request_finalize_cb = client_fcgi_request_finalize;
|
||||||
return &self->client;
|
return &self->client;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue