mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-01 22:58:49 -04:00
conf: introduce safe_strtol_base()
It is useful to parse hexadecimal strings, too. Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
0e2b167e93
commit
f547b2e35f
3 changed files with 5 additions and 9 deletions
|
|
@ -668,14 +668,14 @@ static int safe_strtoll(const char *str, long long *val)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int safe_strtol(const char *str, long *val)
|
||||
int safe_strtol_base(const char *str, long *val, int base)
|
||||
{
|
||||
char *end;
|
||||
long v;
|
||||
if (!*str)
|
||||
return -EINVAL;
|
||||
errno = 0;
|
||||
v = strtol(str, &end, 0);
|
||||
v = strtol(str, &end, base);
|
||||
if (errno)
|
||||
return -errno;
|
||||
if (*end)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue