Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sven Gestegård Robertz
LabComm
Commits
0c09f573
Commit
0c09f573
authored
Oct 25, 2014
by
Sven Gestegård Robertz
Browse files
alloc and copy pragma_type
parent
62481855
Changes
1
Show whitespace changes
Inline
Side-by-side
lib/c/labcomm_encoder.c
View file @
0c09f573
...
...
@@ -100,22 +100,31 @@ struct labcomm_encoder *labcomm_pragma_builder_new(
char
*
pragma_type
)
{
struct
labcomm_writer
*
dyn_writer
=
labcomm_dynamic_buffer_writer_new
(
e
->
memory
);
struct
labcomm_encoder
*
mdt
=
labcomm_encoder_new
(
dyn_writer
,
struct
labcomm_encoder
*
pb
=
labcomm_encoder_new
(
dyn_writer
,
e
->
error
,
e
->
memory
,
e
->
scheduler
);
size_t
tlen
=
1
+
strlen
(
pragma_type
);
char
*
ptype
=
labcomm_memory_alloc
(
e
->
memory
,
1
,
tlen
);
if
(
ptype
)
{
strncpy
(
ptype
,
pragma_type
,
tlen
);
}
//XXX TODO: and else?
struct
pragma_packet_builder
*
ctxt
=
labcomm_memory_alloc
(
e
->
memory
,
1
,
sizeof
(
struct
pragma_packet_builder
));
if
(
ctxt
){
ctxt
->
pragma_type
=
p
ragma_
type
;
ctxt
->
pragma_type
=
ptype
;
ctxt
->
parent
=
e
;
}
mdt
->
context_type
=
LABCOMM_PRAGMA
;
mdt
->
context
=
ctxt
;
return
mdt
;
pb
->
context_type
=
LABCOMM_PRAGMA
;
pb
->
context
=
ctxt
;
return
pb
;
}
//HERE BE DRAGONS! Copied from decoder.c
...
...
@@ -196,6 +205,8 @@ int labcomm_pragma_send(struct labcomm_encoder* e)
err
=
p
->
writer
->
error
;
}
free_encoder:
//XXX are these needed, or is that done in encoder_free?
labcomm_memory_free
(
e
->
memory
,
1
,
ctx
->
pragma_type
);
labcomm_memory_free
(
e
->
memory
,
1
,
ctx
);
labcomm_encoder_free
(
e
);
return
err
;
...
...
Write
Preview
Supports
Markdown
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