Skip to content

Commit 59060f6

Browse files
committed
Refactor: Move http_buf_alloc and http_buf_free to http_server.h as static inline function
Signed-off-by: Nick Huang <[email protected]>
1 parent 384be50 commit 59060f6

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

http_server.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,13 @@ struct http_server_param {
1212

1313
extern int http_server_daemon(void *arg);
1414

15+
static inline void *http_buf_alloc(gfp_t gfp_mask, void *pool_data)
16+
{
17+
return kzalloc(RECV_BUFFER_SIZE, gfp_mask);
18+
}
19+
20+
static inline void http_buf_free(void *element, void *pool_data)
21+
{
22+
kfree(element);
23+
}
1524
#endif

main.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -157,26 +157,13 @@ static void close_listen_socket(struct socket *socket)
157157
sock_release(socket);
158158
}
159159

160-
161-
static void *http_buf_alloc(gfp_t gfp_mask, void *pool_data)
162-
{
163-
return kzalloc(RECV_BUFFER_SIZE, gfp_mask);
164-
}
165-
166-
static void http_buf_free(void *element, void *pool_data)
167-
{
168-
kfree(element);
169-
}
170-
171160
static int __init khttpd_init(void)
172161
{
173162
if (!(http_buf_pool = mempool_create(POOL_MIN_NR, http_buf_alloc,
174163
http_buf_free, NULL))) {
175164
pr_err("failed to create mempool\n");
176165
return -ENOMEM;
177166
}
178-
179-
180167
int err = open_listen_socket(port, backlog, &listen_socket);
181168
if (err < 0) {
182169
pr_err("can't open listen socket\n");

0 commit comments

Comments
 (0)