Browse Source

[multiple] remove buffer_init_buffer()

remove (minor) convenience func; easy to replace

Like buffer_init_string(), buffer_init_buffer() was used in only a few
places at startup or in cold funcs, so better off removed from buffer.c
master
Glenn Strauss 5 months ago
parent
commit
51e141c803
  1. 7
      src/buffer.c
  2. 4
      src/buffer.h
  3. 2
      src/configparser.y
  4. 2
      src/mod_authn_gssapi.c
  5. 4
      src/mod_gnutls.c
  6. 7
      src/network.c
  7. 2
      src/response.c

7
src/buffer.c

@ -17,15 +17,8 @@ buffer* buffer_init(void) {
return b;
}
buffer *buffer_init_buffer(const buffer *src) {
buffer * const b = buffer_init();
buffer_copy_string_len(b, BUF_PTR_LEN(src));
return b;
}
void buffer_free(buffer *b) {
if (NULL == b) return;
free(b->ptr);
free(b);
}

4
src/buffer.h

@ -33,10 +33,6 @@ __attribute_malloc__
__attribute_returns_nonnull__
buffer* buffer_init(void);
__attribute_nonnull__()
__attribute_returns_nonnull__
buffer* buffer_init_buffer(const buffer *src);
void buffer_free(buffer *b); /* b can be NULL */
/* reset b. if NULL != b && NULL != src, move src content to b. reset src. */

2
src/configparser.y

@ -720,7 +720,7 @@ stringop(A) ::= expression(B). {
A = NULL;
if (ctx->ok) {
if (B->type == TYPE_STRING) {
A = buffer_init_buffer(&((data_string*)B)->value);
buffer_copy_buffer((A = buffer_init()), &((data_string*)B)->value);
} else if (B->type == TYPE_INTEGER) {
A = buffer_init();
buffer_append_int(A, ((data_integer *)B)->value);

2
src/mod_authn_gssapi.c

@ -688,7 +688,7 @@ static handler_t mod_authn_gssapi_basic(request_st * const r, void *p_d, const h
}
if (strchr(username->ptr, '@') == NULL) {
user_at_realm = buffer_init_buffer(username);
buffer_copy_buffer((user_at_realm = buffer_init()), username);
buffer_append_str2(user_at_realm, CONST_STR_LEN("@"),
BUF_PTR_LEN(require->realm));
}

4
src/mod_gnutls.c

@ -1260,8 +1260,8 @@ mod_gnutls_acme_tls_1 (handler_ctx *hctx)
#if 0
buffer *privkey = buffer_init_buffer(b);
buffer_append_string_len(b, CONST_STR_LEN(".crt.pem"));
buffer * const privkey = buffer_init();
buffer_append_str2(b, BUF_PTR_LEN(b), CONST_STR_LEN(".crt.pem"));
buffer_append_string_len(privkey, CONST_STR_LEN(".key.pem"));
/*(similar to network_gnutls_load_pemfile() but propagates rc)*/

7
src/network.c

@ -321,7 +321,7 @@ static int network_server_init(server *srv, network_socket_config *s, buffer *ho
srv_socket->sidx = sidx;
srv_socket->is_ssl = s->ssl_enabled;
srv_socket->srv = srv;
srv_socket->srv_token = buffer_init_buffer(host_token);
buffer_copy_buffer((srv_socket->srv_token = buffer_init()), host_token);
srv_socket->srv_token_colon =
network_srv_token_colon(srv_socket->srv_token);
@ -758,8 +758,9 @@ int network_init(server *srv, int stdin_fd) {
force_assert(NULL != srv_socket);
memcpy(srv_socket, srv->srv_sockets_inherited.ptr[i],
sizeof(server_socket));
srv_socket->srv_token =
buffer_init_buffer(srv_socket->srv_token);
const buffer * const srv_token = srv_socket->srv_token;
buffer_copy_buffer((srv_socket->srv_token = buffer_init()),
srv_token);
srv_socket->srv_token_colon =
network_srv_token_colon(srv_socket->srv_token);
network_srv_sockets_append(srv, srv_socket);

2
src/response.c

@ -596,7 +596,7 @@ http_response_errdoc_init (request_st * const r)
const buffer * const vb =
http_header_response_get(r, HTTP_HEADER_WWW_AUTHENTICATE,
CONST_STR_LEN("WWW-Authenticate"));
if (NULL != vb) www_auth = buffer_init_buffer(vb);
if (NULL != vb) buffer_copy_buffer((www_auth = buffer_init()), vb);
}
buffer_reset(&r->physical.path);

Loading…
Cancel
Save