Move get_buffer_size into buffer_helper
parent
4200b4a6d6
commit
85254e21cb
|
@ -1,5 +1,6 @@
|
|||
#include "http_socket.h"
|
||||
#include "../common/socket_helper.h"
|
||||
#include "../common/buffer_helper.h"
|
||||
#include <math.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
|
@ -10,23 +11,6 @@
|
|||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/**
|
||||
* Gets the buffer size to allocate based on the given components.
|
||||
*
|
||||
* @param components An array of null-terminated C strings to measure the length of
|
||||
* @param num_components The number of items in the components array.
|
||||
*
|
||||
* @return The buffer size to allocate, excluding the null terminator
|
||||
*/
|
||||
static size_t get_buffer_size(const char **components, int num_components) {
|
||||
size_t buffer_size = 0;
|
||||
for (int i = 0; i < num_components; i++) {
|
||||
buffer_size += strlen(components[i]);
|
||||
}
|
||||
|
||||
return buffer_size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a basic request into an http_message
|
||||
*
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
#include <string.h>
|
||||
|
||||
/**
|
||||
* Gets the buffer size to allocate based on the given components.
|
||||
*
|
||||
* @param components An array of null-terminated C strings to measure the length of
|
||||
* @param num_components The number of items in the components array.
|
||||
*
|
||||
* @return The buffer size to allocate, excluding the null terminator
|
||||
*/
|
||||
size_t get_buffer_size(const char **components, int num_components) {
|
||||
size_t buffer_size = 0;
|
||||
for (int i = 0; i < num_components; i++) {
|
||||
buffer_size += strlen(components[i]);
|
||||
}
|
||||
|
||||
return buffer_size;
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
#ifndef BUFFER_HELPER_H
|
||||
#define BUFFER_HELPER_H
|
||||
|
||||
#include <string.h>
|
||||
|
||||
size_t get_buffer_size(const char **components, int num_components);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue