Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpim-sw
libcdi
Commits
67c635b4
Commit
67c635b4
authored
Jun 02, 2015
by
Thomas Jahns
🤸
Browse files
Replace myStrDup and myAsprintf with strdup and sprintf in vlist_var.c.
parent
a17c14dc
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/vlist_var.c
View file @
67c635b4
...
...
@@ -14,7 +14,6 @@
#include
"namespace.h"
#include
"serialize.h"
#include
"error.h"
#include
"proprietarySystemWorkarounds.h"
#if defined (HAVE_LIBGRIB_API)
# include "file.h"
...
...
@@ -532,23 +531,31 @@ char* vlistCopyVarName(int vlistId, int varId)
//If a name is set in the variable description, use that.
const
char
*
name
=
vlistptr
->
vars
[
varId
].
name
;
if
(
name
)
return
myS
tr
D
up
(
name
);
if
(
name
)
return
s
tr
d
up
(
name
);
//Otherwise we check if we should use the table of parameter descriptions.
int
param
=
vlistptr
->
vars
[
varId
].
param
;
int
discipline
,
category
,
number
;
cdiDecodeParam
(
param
,
&
number
,
&
category
,
&
discipline
);
char
*
result
=
NULL
;
if
(
discipline
==
255
)
{
int
tableId
=
vlistptr
->
vars
[
varId
].
tableID
;
if
((
name
=
tableInqParNamePtr
(
tableId
,
number
)
))
return
myStrDup
(
name
);
//No luck, fall back to outputting a name of the format "var<num>".
return
myAsprintf
(
"var%d"
,
number
);
if
((
name
=
tableInqParNamePtr
(
tableId
,
number
)
))
result
=
strdup
(
name
);
{
//No luck, fall back to outputting a name of the format "var<num>".
result
=
xmalloc
(
3
+
3
*
sizeof
(
int
)
*
CHAR_BIT
/
8
+
2
);
sprintf
(
result
,
"var%d"
,
number
);
}
}
else
{
result
=
xmalloc
(
5
+
2
+
3
*
(
3
*
sizeof
(
int
)
*
CHAR_BIT
+
1
)
+
1
);
sprintf
(
result
,
"param%d.%d.%d"
,
number
,
category
,
discipline
);
}
//Finally, we fall back to outputting a name of the format "param<num>.<cat>.<dis>".
return
myAsprintf
(
"param%d.%d.%d"
,
number
,
category
,
discipline
)
;
return
result
;
}
/*
...
...
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