Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnishevent
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
varnishevent
Commits
58ed9e04
Commit
58ed9e04
authored
Sep 14, 2015
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement the payload buffer in format.c as a static char buffer
from the heap (rather than a VSB)
parent
6135e7b6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
9 deletions
+11
-9
format.c
src/format.c
+11
-9
No files found.
src/format.c
View file @
58ed9e04
...
@@ -52,9 +52,9 @@ typedef struct compiled_fmt_t {
...
@@ -52,9 +52,9 @@ typedef struct compiled_fmt_t {
unsigned
n
;
unsigned
n
;
}
compiled_fmt_t
;
}
compiled_fmt_t
;
static
struct
vsb
payload_storage
,
*
const
payload
=
&
payload_storage
,
static
struct
vsb
*
scratch
;
*
scratch
;
static
char
*
payload
;
static
char
empty
[]
=
""
;
static
char
empty
[]
=
""
;
static
char
hit
[]
=
"hit"
;
static
char
hit
[]
=
"hit"
;
static
char
miss
[]
=
"miss"
;
static
char
miss
[]
=
"miss"
;
...
@@ -90,20 +90,20 @@ get_payload(const rec_t *rec)
...
@@ -90,20 +90,20 @@ get_payload(const rec_t *rec)
if
(
rec
->
len
<=
config
.
chunk_size
)
if
(
rec
->
len
<=
config
.
chunk_size
)
return
chunk
->
data
;
return
chunk
->
data
;
VSB_clear
(
payload
);
assert
(
rec
->
len
<=
config
.
max_reclen
);
int
n
=
rec
->
len
;
int
n
=
rec
->
len
;
char
*
p
=
payload
;
while
(
n
>
0
)
{
while
(
n
>
0
)
{
CHECK_OBJ_NOTNULL
(
chunk
,
CHUNK_MAGIC
);
CHECK_OBJ_NOTNULL
(
chunk
,
CHUNK_MAGIC
);
int
cp
=
n
;
int
cp
=
n
;
if
(
cp
>
config
.
chunk_size
)
if
(
cp
>
config
.
chunk_size
)
cp
=
config
.
chunk_size
;
cp
=
config
.
chunk_size
;
VSB_bcat
(
payload
,
chunk
->
data
,
cp
);
memcpy
(
p
,
chunk
->
data
,
cp
);
p
+=
cp
;
n
-=
cp
;
n
-=
cp
;
chunk
=
VSTAILQ_NEXT
(
chunk
,
chunklist
);
chunk
=
VSTAILQ_NEXT
(
chunk
,
chunklist
);
}
}
assert
(
VSB_len
(
payload
)
==
rec
->
len
);
return
payload
;
VSB_finish
(
payload
);
return
VSB_data
(
payload
);
}
}
/*
/*
...
@@ -1332,7 +1332,9 @@ FMT_Init(char *err)
...
@@ -1332,7 +1332,9 @@ FMT_Init(char *err)
int
idx
=
0
;
int
idx
=
0
;
char
**
chdrtbl
=
NULL
,
**
bhdrtbl
=
NULL
,
**
rhdrtbl
=
NULL
;
char
**
chdrtbl
=
NULL
,
**
bhdrtbl
=
NULL
,
**
rhdrtbl
=
NULL
;
AN
(
VSB_new
(
payload
,
NULL
,
config
.
max_reclen
+
1
,
VSB_FIXEDLEN
));
payload
=
malloc
(
config
.
max_reclen
);
if
(
payload
==
NULL
)
return
ENOMEM
;
scratch
=
VSB_new_auto
();
scratch
=
VSB_new_auto
();
AN
(
scratch
);
AN
(
scratch
);
...
@@ -1510,7 +1512,7 @@ void
...
@@ -1510,7 +1512,7 @@ void
FMT_Fini
(
void
)
FMT_Fini
(
void
)
{
{
VSB_delete
(
scratch
);
VSB_delete
(
scratch
);
VSB_delet
e
(
payload
);
fre
e
(
payload
);
free_incl
(
cincl
);
free_incl
(
cincl
);
free_incl
(
bincl
);
free_incl
(
bincl
);
...
...
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