From db4e8375982b0756406f6e4537991dd1f863da0a Mon Sep 17 00:00:00 2001 From: Praveen K Paladugu Date: Thu, 19 Dec 2024 08:46:00 -0600 Subject: [PATCH] ch: move curl_data and curl_callback definitions Move the definitions of curl_data and curl_callback to be used within virCHMonitorPutNoContent. Signed-off-by: Praveen K Paladugu Reviewed-by: Michal Privoznik --- src/ch/ch_monitor.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/ch/ch_monitor.c b/src/ch/ch_monitor.c index c9b08b0f75..88df9d4a03 100644 --- a/src/ch/ch_monitor.c +++ b/src/ch/ch_monitor.c @@ -671,6 +671,28 @@ virCHMonitorCurlPerform(CURL *handle) return responseCode; } +struct curl_data { + char *content; + size_t size; +}; + +static size_t +curl_callback(void *contents, size_t size, size_t nmemb, void *userp) +{ + size_t content_size = size * nmemb; + struct curl_data *data = userp; + + if (content_size == 0) + return content_size; + + data->content = g_realloc(data->content, data->size + content_size); + + memcpy(&(data->content[data->size]), contents, content_size); + data->size += content_size; + + return content_size; +} + int virCHMonitorPutNoContent(virCHMonitor *mon, const char *endpoint) { @@ -698,28 +720,6 @@ virCHMonitorPutNoContent(virCHMonitor *mon, const char *endpoint) return ret; } -struct curl_data { - char *content; - size_t size; -}; - -static size_t -curl_callback(void *contents, size_t size, size_t nmemb, void *userp) -{ - size_t content_size = size * nmemb; - struct curl_data *data = userp; - - if (content_size == 0) - return content_size; - - data->content = g_realloc(data->content, data->size + content_size); - - memcpy(&(data->content[data->size]), contents, content_size); - data->size += content_size; - - return content_size; -} - static int virCHMonitorGet(virCHMonitor *mon, const char *endpoint, virJSONValue **response) {