Skip to content
Snippets Groups Projects
Commit a86f634d authored by Andy Green's avatar Andy Green
Browse files

improve static allocation notice

parent 46596481
Branches
Tags
No related merge requests found
......@@ -1630,11 +1630,11 @@ libwebsocket_create_context(struct lws_context_creation_info *info)
context->options = info->options;
/* to reduce this allocation, */
context->max_fds = getdtablesize();
lwsl_notice(" max fd tracked: %u\n", context->max_fds);
lwsl_notice(" static allocation: %u bytes\n",
sizeof(struct libwebsocket_context) +
(sizeof(struct pollfd) * context->max_fds) +
(sizeof(struct libwebsocket *) * context->max_fds));
lwsl_notice(" static allocation: %u + (%u x %u fds) = %u bytes\n",
sizeof(struct libwebsocket_context),
sizeof(struct pollfd) + sizeof(struct libwebsocket *),
context->max_fds,
sizeof(struct libwebsocket_context) + ((sizeof(struct pollfd) + sizeof(struct libwebsocket *)) * context->max_fds));
context->fds = (struct pollfd *)malloc(sizeof(struct pollfd) * context->max_fds);
if (context->fds == NULL) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment