Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
c632af8a
Commit
c632af8a
authored
Jan 02, 2012
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pack the memitem a bit smarter and drop the payload element which costs
us 8 bytes per allocation.
parent
473e58c0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
7 deletions
+5
-7
cache_mempool.c
bin/varnishd/cache/cache_mempool.c
+5
-7
No files found.
bin/varnishd/cache/cache_mempool.c
View file @
c632af8a
...
...
@@ -29,6 +29,7 @@
*/
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include "config.h"
...
...
@@ -40,10 +41,9 @@
struct
memitem
{
unsigned
magic
;
#define MEMITEM_MAGIC 0x42e55401
VTAILQ_ENTRY
(
memitem
)
list
;
unsigned
size
;
VTAILQ_ENTRY
(
memitem
)
list
;
double
touched
;
char
payload
;
};
VTAILQ_HEAD
(
memhead_s
,
memitem
);
...
...
@@ -92,8 +92,6 @@ mpl_alloc(const struct mempool *mpl)
* of the list not getting too old.
*/
#include <stdio.h>
static
void
*
mpl_guard
(
void
*
priv
)
{
...
...
@@ -309,7 +307,7 @@ MPL_Get(struct mempool *mpl, unsigned *size)
CHECK_OBJ_NOTNULL
(
mi
,
MEMITEM_MAGIC
);
/* Throw away sizeof info for FlexeLint: */
return
((
void
*
)(
uintptr_t
)
&
mi
->
payload
);
return
((
void
*
)(
uintptr_t
)
(
mi
+
1
)
);
}
void
...
...
@@ -320,7 +318,7 @@ MPL_Free(struct mempool *mpl, void *item)
CHECK_OBJ_NOTNULL
(
mpl
,
MEMPOOL_MAGIC
);
AN
(
item
);
mi
=
(
void
*
)((
uintptr_t
)
item
-
offsetof
(
struct
memitem
,
payload
));
mi
=
(
void
*
)((
uintptr_t
)
item
-
sizeof
(
*
mi
));
CHECK_OBJ_NOTNULL
(
mi
,
MEMITEM_MAGIC
);
memset
(
item
,
0
,
mi
->
size
);
...
...
@@ -348,6 +346,6 @@ void
MPL_AssertSane
(
void
*
item
)
{
struct
memitem
*
mi
;
mi
=
(
void
*
)((
uintptr_t
)
item
-
offsetof
(
struct
memitem
,
payload
));
mi
=
(
void
*
)((
uintptr_t
)
item
-
sizeof
(
*
mi
));
CHECK_OBJ_NOTNULL
(
mi
,
MEMITEM_MAGIC
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment