Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
FORMUS3IC_LAS3
/
embb
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
1eebbf2d
authored
Nov 03, 2014
by
Marcus Winter
Committed by
unknown
Dec 11, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mtapi_network_c: buffer push/pop operations return number of bytes pushed
parent
a71ceed0
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
11 deletions
+25
-11
mtapi_network_c/src/embb_mtapi_network_buffer.c
+3
-3
mtapi_network_c/test/embb_mtapi_network_test_buffer.cc
+22
-8
No files found.
mtapi_network_c/src/embb_mtapi_network_buffer.c
View file @
1eebbf2d
...
@@ -45,7 +45,7 @@ int embb_mtapi_network_buffer_push_back_int16(
...
@@ -45,7 +45,7 @@ int embb_mtapi_network_buffer_push_back_int16(
}
}
memcpy
(
that
->
data
+
that
->
size
,
&
value
,
2
);
memcpy
(
that
->
data
+
that
->
size
,
&
value
,
2
);
that
->
size
+=
2
;
that
->
size
+=
2
;
return
1
;
return
2
;
}
}
int
embb_mtapi_network_buffer_push_back_int32
(
int
embb_mtapi_network_buffer_push_back_int32
(
...
@@ -56,7 +56,7 @@ int embb_mtapi_network_buffer_push_back_int32(
...
@@ -56,7 +56,7 @@ int embb_mtapi_network_buffer_push_back_int32(
}
}
memcpy
(
that
->
data
+
that
->
size
,
&
value
,
4
);
memcpy
(
that
->
data
+
that
->
size
,
&
value
,
4
);
that
->
size
+=
4
;
that
->
size
+=
4
;
return
1
;
return
4
;
}
}
int
embb_mtapi_network_buffer_push_back_rawdata
(
int
embb_mtapi_network_buffer_push_back_rawdata
(
...
@@ -68,7 +68,7 @@ int embb_mtapi_network_buffer_push_back_rawdata(
...
@@ -68,7 +68,7 @@ int embb_mtapi_network_buffer_push_back_rawdata(
}
}
memcpy
(
that
->
data
+
that
->
size
,
rawdata
,
size
);
memcpy
(
that
->
data
+
that
->
size
,
rawdata
,
size
);
that
->
size
+=
size
;
that
->
size
+=
size
;
return
1
;
return
size
;
}
}
int
embb_mtapi_network_buffer_pop_front_int8
(
int
embb_mtapi_network_buffer_pop_front_int8
(
...
...
mtapi_network_c/test/embb_mtapi_network_test_buffer.cc
View file @
1eebbf2d
...
@@ -25,8 +25,11 @@
...
@@ -25,8 +25,11 @@
*/
*/
#include <embb_mtapi_network_test_buffer.h>
#include <embb_mtapi_network_test_buffer.h>
#include <embb_mtapi_network_buffer.h>
#include <embb_mtapi_network_buffer.h>
#include <embb/base/c/memory_allocation.h>
NetworkBufferTest
::
NetworkBufferTest
()
{
NetworkBufferTest
::
NetworkBufferTest
()
{
CreateUnit
(
"mtapi network buffer test"
).
Add
(
&
NetworkBufferTest
::
TestBasic
,
this
);
CreateUnit
(
"mtapi network buffer test"
).
Add
(
&
NetworkBufferTest
::
TestBasic
,
this
);
...
@@ -34,20 +37,31 @@ NetworkBufferTest::NetworkBufferTest() {
...
@@ -34,20 +37,31 @@ NetworkBufferTest::NetworkBufferTest() {
void
NetworkBufferTest
::
TestBasic
()
{
void
NetworkBufferTest
::
TestBasic
()
{
embb_mtapi_network_buffer_t
buffer
;
embb_mtapi_network_buffer_t
buffer
;
int
err
;
embb_mtapi_network_buffer_initialize
(
&
buffer
,
1024
);
embb_mtapi_network_buffer_initialize
(
&
buffer
,
1024
);
embb_mtapi_network_buffer_push_back_int8
(
&
buffer
,
-
1
);
embb_mtapi_network_buffer_push_back_int16
(
&
buffer
,
-
2
);
err
=
embb_mtapi_network_buffer_push_back_int8
(
&
buffer
,
-
1
);
PT_EXPECT
(
err
==
1
);
err
=
embb_mtapi_network_buffer_push_back_int16
(
&
buffer
,
-
2
);
PT_EXPECT
(
err
==
2
);
int8_t
val8
=
0
;
int8_t
val8
=
0
;
int
result
=
embb_mtapi_network_buffer_pop_front_int8
(
&
buffer
,
&
val8
);
err
=
embb_mtapi_network_buffer_pop_front_int8
(
&
buffer
,
&
val8
);
PT_EXPECT
(
result
==
1
);
PT_EXPECT
(
err
==
1
);
PT_EXPECT
(
val8
==
-
1
);
PT_EXPECT
(
val8
==
-
1
);
int32_t
val32
=
0
;
int32_t
val32
=
0
;
result
=
embb_mtapi_network_buffer_pop_front_int32
(
&
buffer
,
&
val32
);
err
=
embb_mtapi_network_buffer_pop_front_int32
(
&
buffer
,
&
val32
);
PT_EXPECT
(
result
==
0
);
PT_EXPECT
(
err
==
0
);
PT_EXPECT
(
val32
==
0
);
PT_EXPECT
(
val32
==
0
);
int16_t
val16
=
0
;
int16_t
val16
=
0
;
result
=
embb_mtapi_network_buffer_pop_front_int16
(
&
buffer
,
&
val16
);
err
=
embb_mtapi_network_buffer_pop_front_int16
(
&
buffer
,
&
val16
);
PT_EXPECT
(
result
==
2
);
PT_EXPECT
(
err
==
2
);
PT_EXPECT
(
val16
==
-
2
);
PT_EXPECT
(
val16
==
-
2
);
embb_mtapi_network_buffer_finalize
(
&
buffer
);
embb_mtapi_network_buffer_finalize
(
&
buffer
);
PT_EXPECT
(
embb_get_bytes_allocated
()
==
0
);
}
}
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