Merge pull request 'Make thing build with macOS clang' (#1) from fix/macos-clang-doesnt-compile into main
Reviewed-on: #1
This commit is contained in:
@@ -64,7 +64,7 @@ void start_http_server(http_server_t* http_server, const char *addr, const short
|
||||
sa.sa_handler = handle_sigint;
|
||||
sigemptyset(&sa.sa_mask);
|
||||
sa.sa_flags = 0;
|
||||
sigaction(SIGINT, &sa, nullptr);
|
||||
sigaction(SIGINT, &sa, NULL);
|
||||
|
||||
printf("Server is listening on %s:%d...\n", addr, port);
|
||||
|
||||
@@ -124,7 +124,7 @@ void process_conn(const http_server_t* http_server, const int server_fd, struct
|
||||
char *header_val = malloc(1024);
|
||||
size_t header_val_length = 0;
|
||||
|
||||
http_request.http_content = nullptr;
|
||||
http_request.http_content = NULL;
|
||||
http_request.http_content_len = 0;
|
||||
|
||||
// TODO: Needs functionality to continue reading the request if didn't receive the whole thing,
|
||||
@@ -266,7 +266,7 @@ void process_conn(const http_server_t* http_server, const int server_fd, struct
|
||||
for (int i = 0; i < http_response->http_headers->cap; i++)
|
||||
{
|
||||
const pair_t* iter = http_response->http_headers->list[i];
|
||||
while (iter != nullptr)
|
||||
while (iter != NULL)
|
||||
{
|
||||
append_fmt(response_sb, "%s: %s\r\n", iter->key, iter->val);
|
||||
iter = iter->next;
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#define SIMPLEHTTPSERVER_H
|
||||
|
||||
#include <netdb.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -28,13 +28,13 @@ char* get(const hashmap_t* this, const char* key)
|
||||
const unsigned hash = hashcode(this, key);
|
||||
|
||||
const pair_t* existing_pair = this->list[hash];
|
||||
if (existing_pair == nullptr)
|
||||
return nullptr;
|
||||
if (existing_pair == NULL)
|
||||
return NULL;
|
||||
|
||||
while (strcmp(existing_pair->key, key) != 0)
|
||||
{
|
||||
if (existing_pair->next == nullptr)
|
||||
return nullptr;
|
||||
if (existing_pair->next == NULL)
|
||||
return NULL;
|
||||
existing_pair = existing_pair->next;
|
||||
}
|
||||
|
||||
@@ -48,11 +48,11 @@ void set(hashmap_t* this, char* key, char* val)
|
||||
pair_t* new_pair = malloc(sizeof *new_pair);
|
||||
new_pair->key = key;
|
||||
new_pair->val = val;
|
||||
new_pair->next = nullptr;
|
||||
new_pair->next = NULL;
|
||||
|
||||
pair_t* existing_pair = this->list[hash];
|
||||
|
||||
if (existing_pair == nullptr)
|
||||
if (existing_pair == NULL)
|
||||
{
|
||||
this->list[hash] = new_pair;
|
||||
this->len++;
|
||||
@@ -63,7 +63,7 @@ void set(hashmap_t* this, char* key, char* val)
|
||||
return;
|
||||
}
|
||||
|
||||
while (existing_pair->next != nullptr)
|
||||
while (existing_pair->next != NULL)
|
||||
{
|
||||
if (strcmp(existing_pair->key, key) == 0)
|
||||
{
|
||||
@@ -94,7 +94,7 @@ void expand_hash_map(hashmap_t* this)
|
||||
for (int i = 0; i < old_cap; i++)
|
||||
{
|
||||
pair_t* iter = old_list[i];
|
||||
while (iter != nullptr)
|
||||
while (iter != NULL)
|
||||
{
|
||||
set(this, iter->key, iter->val);
|
||||
pair_t* prev_iter = iter;
|
||||
@@ -111,7 +111,7 @@ void free_hash_map(const hashmap_t* this)
|
||||
for (int i = 0; i < this->cap; i++)
|
||||
{
|
||||
pair_t* iter = this->list[i];
|
||||
while (iter != nullptr)
|
||||
while (iter != NULL)
|
||||
{
|
||||
pair_t* prev_iter = iter;
|
||||
iter = iter->next;
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
string_builder_t* new_string_builder()
|
||||
{
|
||||
string_builder_t* sb = malloc(sizeof *sb);
|
||||
sb->first = nullptr;
|
||||
sb->last = nullptr;
|
||||
sb->first = NULL;
|
||||
sb->last = NULL;
|
||||
sb->char_count = 0;
|
||||
return sb;
|
||||
}
|
||||
@@ -19,7 +19,7 @@ string_builder_t* new_string_builder()
|
||||
char* string_builder_to_string(const string_builder_t* sb)
|
||||
{
|
||||
char* str = malloc(sb->char_count + 1);
|
||||
if (!str) return nullptr;
|
||||
if (!str) return NULL;
|
||||
|
||||
char* p = str;
|
||||
|
||||
@@ -35,7 +35,7 @@ char* string_builder_to_string(const string_builder_t* sb)
|
||||
void free_string_builder(string_builder_t* sb)
|
||||
{
|
||||
string_builder_part_t* iter = sb->first;
|
||||
while (iter != nullptr)
|
||||
while (iter != NULL)
|
||||
{
|
||||
string_builder_part_t* prev = iter;
|
||||
iter = iter->next;
|
||||
@@ -43,15 +43,15 @@ void free_string_builder(string_builder_t* sb)
|
||||
free(prev);
|
||||
}
|
||||
|
||||
sb->first = nullptr;
|
||||
sb->last = nullptr;
|
||||
sb->first = NULL;
|
||||
sb->last = NULL;
|
||||
free(sb);
|
||||
}
|
||||
|
||||
void append_part(string_builder_t* sb, string_builder_part_t* part)
|
||||
{
|
||||
sb->char_count += part->len;
|
||||
if (sb->last == nullptr)
|
||||
if (sb->last == NULL)
|
||||
{
|
||||
sb->first = part;
|
||||
sb->last = part;
|
||||
@@ -106,7 +106,7 @@ void append_fmt(string_builder_t* sb, const char* fmt, ...) {
|
||||
|
||||
va_list args_copy;
|
||||
va_copy(args_copy, args);
|
||||
const int len = vsnprintf(nullptr, 0, fmt, args_copy);
|
||||
const int len = vsnprintf(NULL, 0, fmt, args_copy);
|
||||
va_end(args_copy);
|
||||
|
||||
if (len < 0) {
|
||||
|
||||
Reference in New Issue
Block a user