Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libcdi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mpim-sw
libcdi
Commits
910f640e
Commit
910f640e
authored
3 years ago
by
Thomas Jahns
Browse files
Options
Downloads
Patches
Plain Diff
Fix bug in buffer size of C++ wrapper.
parent
d6e8fc8d
No related branches found
No related tags found
1 merge request
!14
Draft: K202125/cdi 1.8.x pio merge followup
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
interfaces/cdi.cpp
+6
-6
6 additions, 6 deletions
interfaces/cdi.cpp
interfaces/cdi.hpp
+4
-2
4 additions, 2 deletions
interfaces/cdi.hpp
interfaces/ruby/cdiobj_wrap.cpp
+6
-7
6 additions, 7 deletions
interfaces/ruby/cdiobj_wrap.cpp
with
16 additions
and
15 deletions
interfaces/cdi.cpp
+
6
−
6
View file @
910f640e
...
...
@@ -19,9 +19,9 @@ extern "C" {
*/
CdiGrid
::
CdiGrid
()
{
gridID
=
-
1
;
}
CdiGrid
::
CdiGrid
(
int
gridid
)
{
char
_name
[
C
HARSIZ
E
];
char
_xname
[
C
HARSIZ
E
],
_xlongname
[
C
HARSIZ
E
],
_xstdname
[
C
HARSIZ
E
],
_xunits
[
C
HARSIZ
E
];
char
_yname
[
C
HARSIZ
E
],
_ylongname
[
C
HARSIZ
E
],
_ystdname
[
C
HARSIZ
E
],
_yunits
[
C
HARSIZ
E
];
char
_name
[
C
DI_MAX_NAM
E
];
char
_xname
[
C
DI_MAX_NAM
E
],
_xlongname
[
C
DI_MAX_NAM
E
],
_xstdname
[
C
DI_MAX_NAM
E
],
_xunits
[
C
DI_MAX_NAM
E
];
char
_yname
[
C
DI_MAX_NAM
E
],
_ylongname
[
C
DI_MAX_NAM
E
],
_ystdname
[
C
DI_MAX_NAM
E
],
_yunits
[
C
DI_MAX_NAM
E
];
gridID
=
gridid
;
type
=
gridInqType
(
gridID
);
...
...
@@ -208,7 +208,7 @@ CdiTaxis::~CdiTaxis() { if (taxisID >= 0) taxisID = -1; }
*/
CdiZaxis
::
CdiZaxis
()
{
zaxisID
=
-
1
;
}
CdiZaxis
::
CdiZaxis
(
int
zaxisid
)
{
char
name
[
C
HARSIZ
E
],
longname
[
C
HARSIZ
E
],
units
[
C
HARSIZ
E
];
char
name
[
C
DI_MAX_NAM
E
],
longname
[
C
DI_MAX_NAM
E
],
units
[
C
DI_MAX_NAM
E
];
zaxisID
=
zaxisid
;
size
=
zaxisInqSize
(
zaxisID
);
...
...
@@ -243,7 +243,7 @@ CdiZaxis::~CdiZaxis() { if (zaxisID >= 0) zaxisID = -1; }
*/
CdiVariable
::
CdiVariable
()
{
size
=
-
1
;
}
CdiVariable
::
CdiVariable
(
int
streamid
,
int
vlistid
,
int
varid
)
{
char
_name
[
C
HARSIZ
E
],
_longname
[
C
HARSIZ
E
],
_units
[
C
HARSIZ
E
],
_stdname
[
C
HARSIZ
E
];
char
_name
[
C
DI_MAX_NAM
E
],
_longname
[
C
DI_MAX_NAM
E
],
_units
[
C
DI_MAX_NAM
E
],
_stdname
[
C
DI_MAX_NAM
E
];
streamID
=
streamid
;
vlistID
=
vlistid
;
varID
=
varid
;
...
...
@@ -399,7 +399,7 @@ Cdi::getGrids() {
void
Cdi
::
getVars
()
{
char
name
[
C
HARSIZ
E
];
char
name
[
C
DI_MAX_NAM
E
];
int
varID
,
code
;
// std::cout << vlistID << std::endl;
for
(
varID
=
0
;
varID
<
nvars
;
varID
++
)
...
...
This diff is collapsed.
Click to expand it.
interfaces/cdi.hpp
+
4
−
2
View file @
910f640e
...
...
@@ -5,7 +5,9 @@
// (2.0.7 and earlier) with newer STL which no longer include cstddef
#include
<cstddef>
#define CHARSIZE 128
extern
"C"
{
#include
<cdi.h>
}
class
CdiGrid
{
public:
...
...
@@ -44,7 +46,7 @@ class CdiTaxis {
int
ntsteps
,
unit
;
int
rdate
,
rtime
,
vdate
,
vtime
;
int
type
,
calendar
,
hasBounds
;
char
name
[
C
HARSIZ
E
];
char
name
[
C
DI_MAX_NAM
E
];
const
char
*
unitname
;
};
...
...
This diff is collapsed.
Click to expand it.
interfaces/ruby/cdiobj_wrap.cpp
+
6
−
7
View file @
910f640e
...
...
@@ -29017,7 +29017,7 @@ _wrap_CdiTaxis_name_set(int argc, VALUE *argv, VALUE self) {
char *arg2 ;
void *argp1 = 0 ;
int res1 = 0 ;
char temp2[
128
] ;
char temp2[
CDI_MAX_NAME
] ;
int res2 ;
if ((argc < 1) || (argc > 1)) {
...
...
@@ -29028,13 +29028,13 @@ _wrap_CdiTaxis_name_set(int argc, VALUE *argv, VALUE self) {
SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CdiTaxis *","name", 1, self ));
}
arg1 = reinterpret_cast< CdiTaxis * >(argp1);
res2 = SWIG_AsCharArray(argv[0], temp2,
128
);
res2 = SWIG_AsCharArray(argv[0], temp2,
CDI_MAX_NAME
);
if (!SWIG_IsOK(res2)) {
SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "char [
128
]","name", 2, argv[0] ));
SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "char [
CDI_MAX_NAME
]","name", 2, argv[0] ));
}
arg2 = reinterpret_cast< char * >(temp2);
if (arg2) memcpy(arg1->name,arg2,
128
*sizeof(char));
else memset(arg1->name,0,
128
*sizeof(char));
if (arg2) memcpy(arg1->name,arg2,
CDI_MAX_NAME
*sizeof(char));
else memset(arg1->name,0,
CDI_MAX_NAME
*sizeof(char));
return Qnil;
fail:
return Qnil;
...
...
@@ -29059,7 +29059,7 @@ _wrap_CdiTaxis_name_get(int argc, VALUE *argv, VALUE self) {
arg1 = reinterpret_cast< CdiTaxis * >(argp1);
result = (char *)(char *) ((arg1)->name);
{
size_t size = SWIG_strnlen(result,
128
);
size_t size = SWIG_strnlen(result,
CDI_MAX_NAME
);
...
...
@@ -33576,7 +33576,6 @@ SWIGEXPORT void Init_CdiObj(void) {
SwigClassGridsMap.mark = 0;
SwigClassGridsMap.destroy = (void (*)(void *)) free_std_map_Sl_int_Sc_CdiGrid_Sg_;
SwigClassGridsMap.trackObjects = 0;
rb_define_const(mCdiObj, "CHARSIZE", SWIG_From_int(static_cast< int >(128)));
SwigClassCdiGrid.klass = rb_define_class_under(mCdiObj, "CdiGrid", rb_cObject);
SWIG_TypeClientData(SWIGTYPE_p_CdiGrid, (void *) &SwigClassCdiGrid);
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment