Skip to content

Commit 80bd6b0

Browse files
committed
Updated license and renamed destructor functions
1 parent 85c64e8 commit 80bd6b0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+86
-86
lines changed

COPYING

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
BSD 2-Clause License
22

3-
Copyright (c) 2023, Andrea Giacomo Baldan
3+
Copyright (c) 2025, Andrea Giacomo Baldan
44
All rights reserved.
55

66
Redistribution and use in source and binary forms, with or without

src/bst.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* BSD 2-Clause License
33
*
4-
* Copyright (c) 2023 Andrea Giacomo Baldan All rights reserved.
4+
* Copyright (c) 2025 Andrea Giacomo Baldan All rights reserved.
55
*
66
* Redistribution and use in source and binary forms, with or without
77
* modification, are permitted provided that the following conditions are met:

src/bst.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* BSD 2-Clause License
33
*
4-
* Copyright (c) 2023 Andrea Giacomo Baldan All rights reserved.
4+
* Copyright (c) 2025 Andrea Giacomo Baldan All rights reserved.
55
*
66
* Redistribution and use in source and binary forms, with or without
77
* modification, are permitted provided that the following conditions are met:
@@ -45,6 +45,6 @@ struct bst_node *bst_search(const struct bst_node *, unsigned char);
4545

4646
struct bst_node *bst_delete(struct bst_node *, unsigned char);
4747

48-
void bst_destroy(struct bst_node *, void (*free_fn)(struct bst_node *));
48+
void bst_free(struct bst_node *, void (*free_fn)(struct bst_node *));
4949

5050
#endif

src/config.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* BSD 2-Clause License
22
*
3-
* Copyright (c) 2023, Andrea Giacomo Baldan All rights reserved.
3+
* Copyright (c) 2025, Andrea Giacomo Baldan All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
66
* modification, are permitted provided that the following conditions are met:

src/config.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* BSD 2-Clause License
22
*
3-
* Copyright (c) 2023, Andrea Giacomo Baldan All rights reserved.
3+
* Copyright (c) 2025, Andrea Giacomo Baldan All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
66
* modification, are permitted provided that the following conditions are met:

src/ev.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* BSD 2-Clause License
22
*
3-
* Copyright (c) 2023, Andrea Giacomo Baldan All rights reserved.
3+
* Copyright (c) 2025, Andrea Giacomo Baldan All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
66
* modification, are permitted provided that the following conditions are met:

src/ev.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* BSD 2-Clause License
22
*
3-
* Copyright (c) 2023, Andrea Giacomo Baldan All rights reserved.
3+
* Copyright (c) 2025, Andrea Giacomo Baldan All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
66
* modification, are permitted provided that the following conditions are met:

src/handlers.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* BSD 2-Clause License
22
*
3-
* Copyright (c) 2023, Andrea Giacomo Baldan All rights reserved.
3+
* Copyright (c) 2025, Andrea Giacomo Baldan All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
66
* modification, are permitted provided that the following conditions are met:
@@ -86,8 +86,8 @@ static void session_free(const struct ref *refcount)
8686
{
8787
struct client_session *session =
8888
container_of(refcount, struct client_session, refcount);
89-
list_destroy(session->subscriptions, 0);
90-
list_destroy(session->outgoing_msgs, 0);
89+
list_free(session->subscriptions, 0);
90+
list_free(session->outgoing_msgs, 0);
9191
if (has_inflight(session)) {
9292
for (int i = 0; i < MAX_INFLIGHT_MSGS; ++i) {
9393
if (session->i_msgs[i].packet)

src/handlers.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* BSD 2-Clause License
22
*
3-
* Copyright (c) 2023, Andrea Giacomo Baldan All rights reserved.
3+
* Copyright (c) 2025, Andrea Giacomo Baldan All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
66
* modification, are permitted provided that the following conditions are met:

src/iterator.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* BSD 2-Clause License
33
*
4-
* Copyright (c) 2023, Andrea Giacomo Baldan All rights reserved.
4+
* Copyright (c) 2025, Andrea Giacomo Baldan All rights reserved.
55
*
66
* Redistribution and use in source and binary forms, with or without
77
* modification, are permitted provided that the following conditions are met:
@@ -50,7 +50,7 @@ void iter_init(struct iterator *i, void *iterable,
5050
iter_next(i);
5151
}
5252

53-
void iter_destroy(struct iterator *i) { free_memory(i); }
53+
void iter_free(struct iterator *i) { free_memory(i); }
5454

5555
/*
5656
* Advance the iterator ptr to the next item in the iterable collection

src/iterator.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* BSD 2-Clause License
33
*
4-
* Copyright (c) 2023, Andrea Giacomo Baldan All rights reserved.
4+
* Copyright (c) 2025, Andrea Giacomo Baldan All rights reserved.
55
*
66
* Redistribution and use in source and binary forms, with or without
77
* modification, are permitted provided that the following conditions are met:
@@ -47,7 +47,7 @@ struct iterator {
4747
struct iterator *iter_new(void *, void (*next)(struct iterator *));
4848
void iter_init(struct iterator *, void *, void (*next)(struct iterator *));
4949
struct iterator *iter_next(struct iterator *);
50-
void iter_destroy(struct iterator *);
50+
void iter_free(struct iterator *);
5151

5252
#define FOREACH(it) for (; it && it->ptr; it = iter_next(it))
5353

src/list.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* BSD 2-Clause License
22
*
3-
* Copyright (c) 2023, Andrea Giacomo Baldan
3+
* Copyright (c) 2025, Andrea Giacomo Baldan
44
* All rights reserved.
55
*
66
* Redistribution and use in source and binary forms, with or without
@@ -49,7 +49,7 @@ List *list_new(int (*destructor)(struct list_node *))
4949
/*
5050
* Destroy a list, releasing all allocated memory
5151
*/
52-
void list_destroy(List *l, int deep)
52+
void list_free(List *l, int deep)
5353
{
5454
if (!l)
5555
return;

src/list.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* BSD 2-Clause License
22
*
3-
* Copyright (c) 2023, Andrea Giacomo Baldan
3+
* Copyright (c) 2025, Andrea Giacomo Baldan
44
* All rights reserved.
55
*
66
* Redistribution and use in source and binary forms, with or without
@@ -56,7 +56,7 @@ List *list_new(int (*destructor)(struct list_node *));
5656
* Release a list, accept a integer flag to control the depth of the free call
5757
* (e.g. going to free also data field of every node)
5858
*/
59-
void list_destroy(List *, int);
59+
void list_free(List *, int);
6060

6161
/* Return list size */
6262
unsigned long list_size(const List *);

src/logging.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* BSD 2-Clause License
22
*
3-
* Copyright (c) 2023, Andrea Giacomo Baldan All rights reserved.
3+
* Copyright (c) 2025, Andrea Giacomo Baldan All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
66
* modification, are permitted provided that the following conditions are met:

src/logging.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* BSD 2-Clause License
22
*
3-
* Copyright (c) 2023, Andrea Giacomo Baldan All rights reserved.
3+
* Copyright (c) 2025, Andrea Giacomo Baldan All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
66
* modification, are permitted provided that the following conditions are met:

src/memory.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* BSD 2-Clause License
22
*
3-
* Copyright (c) 2023, Andrea Giacomo Baldan All rights reserved.
3+
* Copyright (c) 2025, Andrea Giacomo Baldan All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
66
* modification, are permitted provided that the following conditions are met:

src/memory.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* BSD 2-Clause License
22
*
3-
* Copyright (c) 2023, Andrea Giacomo Baldan All rights reserved.
3+
* Copyright (c) 2025, Andrea Giacomo Baldan All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
66
* modification, are permitted provided that the following conditions are met:

src/memorypool.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* BSD 2-Clause License
22
*
3-
* Copyright (c) 2023, Andrea Giacomo Baldan
3+
* Copyright (c) 2025, Andrea Giacomo Baldan
44
* All rights reserved.
55
*
66
* Redistribution and use in source and binary forms, with or without

src/memorypool.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* BSD 2-Clause License
22
*
3-
* Copyright (c) 2023, Andrea Giacomo Baldan
3+
* Copyright (c) 2025, Andrea Giacomo Baldan
44
* All rights reserved.
55
*
66
* Redistribution and use in source and binary forms, with or without

src/mqtt.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* BSD 2-Clause License
22
*
3-
* Copyright (c) 2023, Andrea Giacomo Baldan All rights reserved.
3+
* Copyright (c) 2025, Andrea Giacomo Baldan All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
66
* modification, are permitted provided that the following conditions are met:

src/mqtt.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* BSD 2-Clause License
22
*
3-
* Copyright (c) 2023, Andrea Giacomo Baldan All rights reserved.
3+
* Copyright (c) 2025, Andrea Giacomo Baldan All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
66
* modification, are permitted provided that the following conditions are met:

src/network.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* BSD 2-Clause License
33
*
4-
* Copyright (c) 2023, Andrea Giacomo Baldan All rights reserved.
4+
* Copyright (c) 2025, Andrea Giacomo Baldan All rights reserved.
55
*
66
* Redistribution and use in source and binary forms, with or without
77
* modification, are permitted provided that the following conditions are met:

src/network.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* BSD 2-Clause License
33
*
4-
* Copyright (c) 2023, Andrea Giacomo Baldan All rights reserved.
4+
* Copyright (c) 2025, Andrea Giacomo Baldan All rights reserved.
55
*
66
* Redistribution and use in source and binary forms, with or without
77
* modification, are permitted provided that the following conditions are met:

src/pack.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* BSD 2-Clause License
22
*
3-
* Copyright (c) 2023 Andrea Giacomo Baldan All rights reserved.
3+
* Copyright (c) 2025 Andrea Giacomo Baldan All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
66
* modification, are permitted provided that the following conditions are met:

src/pack.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* BSD 2-Clause License
22
*
3-
* Copyright (c) 2023, Andrea Giacomo Baldan All rights reserved.
3+
* Copyright (c) 2025, Andrea Giacomo Baldan All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
66
* modification, are permitted provided that the following conditions are met:

src/ref.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* BSD 2-Clause License
22
*
3-
* Copyright (c) 2023, Andrea Giacomo Baldan All rights reserved.
3+
* Copyright (c) 2025, Andrea Giacomo Baldan All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
66
* modification, are permitted provided that the following conditions are met:

src/server.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* BSD 2-Clause License
22
*
3-
* Copyright (c) 2023, Andrea Giacomo Baldan All rights reserved.
3+
* Copyright (c) 2025, Andrea Giacomo Baldan All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
66
* modification, are permitted provided that the following conditions are met:
@@ -581,6 +581,7 @@ static void process_mqtt_message(Connection_Context *c, off_t start,
581581
case -ERRCLIENTDC:
582582
// Client disconnected, set resources to be cleaned up
583583
c->state = CS_CLOSING;
584+
shutdown(c->conn.fd, SHUT_RDWR);
584585
break;
585586
case -ERRNOMEM:
586587
log_error(solerr(c->rc));

src/server.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* BSD 2-Clause License
22
*
3-
* Copyright (c) 2023, Andrea Giacomo Baldan All rights reserved.
3+
* Copyright (c) 2025, Andrea Giacomo Baldan All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
66
* modification, are permitted provided that the following conditions are met:

src/sol.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* BSD 2-Clause License
22
*
3-
* Copyright (c) 2023, Andrea Giacomo Baldan All rights reserved.
3+
* Copyright (c) 2025, Andrea Giacomo Baldan All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
66
* modification, are permitted provided that the following conditions are met:

src/sol_internal.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* BSD 2-Clause License
33
*
4-
* Copyright (c) 2023, Andrea Giacomo Baldan All rights reserved.
4+
* Copyright (c) 2025, Andrea Giacomo Baldan All rights reserved.
55
*
66
* Redistribution and use in source and binary forms, with or without
77
* modification, are permitted provided that the following conditions are met:
@@ -256,7 +256,7 @@ struct topic *topic_new(const char *);
256256
/*
257257
* Deallocate the topic name, retained_msg and all its subscribers
258258
*/
259-
void topic_destroy(struct topic *);
259+
void topic_free(struct topic *);
260260

261261
/*
262262
* Allocate a new subscriber struct on the heap referring to the passed in

src/subscriber.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* BSD 2-Clause License
22
*
3-
* Copyright (c) 2023, Andrea Giacomo Baldan All rights reserved.
3+
* Copyright (c) 2025, Andrea Giacomo Baldan All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
66
* modification, are permitted provided that the following conditions are met:
@@ -29,7 +29,7 @@
2929
#include "sol_internal.h"
3030
#include "util.h"
3131

32-
static void subscriber_destroy(const struct ref *);
32+
static void subscriber_free(const struct ref *);
3333

3434
/*
3535
* Allocate memory on the heap to create and return a pointer to a struct
@@ -42,7 +42,7 @@ struct subscriber *subscriber_new(struct client_session *s, unsigned char qos)
4242
struct subscriber *sub = try_alloc(sizeof(*sub));
4343
sub->session = s;
4444
sub->granted_qos = qos;
45-
sub->refcount = (struct ref){.count = 0, .free = subscriber_destroy};
45+
sub->refcount = (struct ref){.count = 0, .free = subscriber_free};
4646
memcpy(sub->id, s->session_id, MQTT_CLIENT_ID_LEN);
4747
return sub;
4848
}
@@ -59,7 +59,7 @@ struct subscriber *subscriber_clone(const struct subscriber *s)
5959
struct subscriber *sub = try_alloc(sizeof(*sub));
6060
sub->session = s->session;
6161
sub->granted_qos = s->granted_qos;
62-
sub->refcount = (struct ref){.count = 0, .free = subscriber_destroy};
62+
sub->refcount = (struct ref){.count = 0, .free = subscriber_free};
6363
memcpy(sub->id, s->id, MQTT_CLIENT_ID_LEN);
6464
return sub;
6565
}
@@ -79,7 +79,7 @@ bool is_subscribed(const struct topic *t, const struct client_session *s)
7979
* Auxiliary function, defines the destructor behavior for subscriber, just
8080
* decreasing the reference counter till 0, then free the memory.
8181
*/
82-
static void subscriber_destroy(const struct ref *r)
82+
static void subscriber_free(const struct ref *r)
8383
{
8484
struct subscriber *sub = container_of(r, struct subscriber, refcount);
8585
free_memory(sub);

src/topic.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* BSD 2-Clause License
22
*
3-
* Copyright (c) 2023, Andrea Giacomo Baldan All rights reserved.
3+
* Copyright (c) 2025, Andrea Giacomo Baldan All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
66
* modification, are permitted provided that the following conditions are met:
@@ -58,7 +58,7 @@ struct topic *topic_new(const char *name)
5858
/*
5959
* Deallocate the topic name, retained_msg and all its subscribers
6060
*/
61-
void topic_destroy(struct topic *t)
61+
void topic_free(struct topic *t)
6262
{
6363
if (!t)
6464
return;

0 commit comments

Comments
 (0)