mirror of
https://github.com/nmap/nmap.git
synced 2026-05-13 08:46:45 +00:00
Move a useful function to nbase
This commit is contained in:
parent
5ae6b75bf4
commit
e9f3b12e07
4 changed files with 105 additions and 10 deletions
|
|
@ -427,6 +427,8 @@ int Snprintf(char *, size_t, const char *, ...)
|
|||
__attribute__ ((format (printf, 3, 4)));
|
||||
|
||||
char *mkstr(const char *start, const char *end);
|
||||
/* Like strchr, but don't go past end. Nulls not handled specially. */
|
||||
const char *strchr_p(const char *str, const char *end, char c);
|
||||
|
||||
int alloc_vsprintf(char **strp, const char *fmt, va_list va)
|
||||
__attribute__ ((format (printf, 2, 0)));
|
||||
|
|
|
|||
|
|
@ -156,6 +156,16 @@ char *mkstr(const char *start, const char *end) {
|
|||
return s;
|
||||
}
|
||||
|
||||
/* Like strchr, but don't go past end. Nulls not handled specially. */
|
||||
const char *strchr_p(const char *str, const char *end, char c) {
|
||||
assert(str && end >= str);
|
||||
for (const char *q = str; q < end; q++) {
|
||||
if (*q == c)
|
||||
return q;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* vsprintf into a dynamically allocated buffer, similar to asprintf in
|
||||
Glibc. Return the length of the buffer or -1 on error. */
|
||||
int alloc_vsprintf(char **strp, const char *fmt, va_list va) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue