Code Review
/
src
/
app-framework-binder.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Update copyright dates
[src/app-framework-binder.git]
/
src
/
afb-token.c
diff --git
a/src/afb-token.c
b/src/afb-token.c
index
b81a87d
..
4e8b5d4
100644
(file)
--- a/
src/afb-token.c
+++ b/
src/afb-token.c
@@
-1,5
+1,5
@@
/*
/*
- * Copyright (C) 2015-20
19
"IoT.bzh"
+ * Copyright (C) 2015-20
20
"IoT.bzh"
* Author "Fulup Ar Foll"
* Author: José Bollo <jose.bollo@iot.bzh>
*
* Author "Fulup Ar Foll"
* Author: José Bollo <jose.bollo@iot.bzh>
*
@@
-86,7
+86,7
@@
int afb_token_get(struct afb_token **token, const char *tokenstring)
/* search the token */
tok = tokenset.first;
/* search the token */
tok = tokenset.first;
- while (tok &&
memcmp(tokenstring, tok->text, length
))
+ while (tok &&
(memcmp(tokenstring, tok->text, length) || tokenstring[length]
))
tok = tok->next;
/* search done */
tok = tok->next;
/* search done */
@@
-96,7
+96,7
@@
int afb_token_get(struct afb_token **token, const char *tokenstring)
rc = 0;
} else {
/* not found, create */
rc = 0;
} else {
/* not found, create */
- tok = malloc(length + sizeof *tok);
+ tok = malloc(length +
1 +
sizeof *tok);
if (!tok)
/* creation failed */
rc = -ENOMEM;
if (!tok)
/* creation failed */
rc = -ENOMEM;
@@
-106,7
+106,7
@@
int afb_token_get(struct afb_token **token, const char *tokenstring)
tokenset.first = tok;
tok->id = tokenset.idgen;
tok->refcount = 1;
tokenset.first = tok;
tok->id = tokenset.idgen;
tok->refcount = 1;
- memcpy(tok->text, tokenstring, length);
+ memcpy(tok->text, tokenstring, length
+ 1
);
rc = 0;
}
}
rc = 0;
}
}
@@
-140,6
+140,7
@@
void afb_token_unref(struct afb_token *token)
pthread_mutex_lock(&tokenset.mutex);
pt = &tokenset.first;
while (*pt && *pt != token)
pthread_mutex_lock(&tokenset.mutex);
pt = &tokenset.first;
while (*pt && *pt != token)
+ pt = &(*pt)->next;
if (*pt)
*pt = token->next;
pthread_mutex_unlock(&tokenset.mutex);
if (*pt)
*pt = token->next;
pthread_mutex_unlock(&tokenset.mutex);
@@
-147,18
+148,6
@@
void afb_token_unref(struct afb_token *token)
}
}
}
}
-/**
- * Check whether the token is valid or not
- *
- * @param token the token to check
- * @return a boolean value: 0 if not valid, 1 if valid
- */
-int afb_token_check(struct afb_token *token)
-{
- /* TODO */
- return 1;
-}
-
/**
* Get the string value of the token
*
/**
* Get the string value of the token
*