Last change
on this file since 660 was 615, checked in by Paul Smedley, 5 years ago |
Add source for uniaud32 based on code from linux kernel 5.4.86
|
File size:
786 bytes
|
Line | |
---|
1 | /*
|
---|
2 | * linux/lib/kasprintf.c
|
---|
3 | *
|
---|
4 | * Copyright (C) 1991, 1992 Linus Torvalds
|
---|
5 | */
|
---|
6 |
|
---|
7 | #include <stdarg.h>
|
---|
8 | #include <linux/export.h>
|
---|
9 | #include <linux/slab.h>
|
---|
10 | #include <linux/types.h>
|
---|
11 | #include <linux/string.h>
|
---|
12 | #include <linux/printk.h>
|
---|
13 | #include <linux/kernel.h>
|
---|
14 |
|
---|
15 | /* Simplified asprintf. */
|
---|
16 | char *kvasprintf(gfp_t gfp, const char *fmt, va_list ap)
|
---|
17 | {
|
---|
18 | unsigned int first, second;
|
---|
19 | char *p;
|
---|
20 | va_list aq;
|
---|
21 |
|
---|
22 | va_copy(aq, ap);
|
---|
23 | first = vsnprintf(NULL, 0, fmt, aq);
|
---|
24 | va_end(aq);
|
---|
25 |
|
---|
26 | p = kmalloc_track_caller(first+1, gfp);
|
---|
27 | if (!p)
|
---|
28 | return NULL;
|
---|
29 |
|
---|
30 | second = vsnprintf(p, first+1, fmt, ap);
|
---|
31 |
|
---|
32 | return p;
|
---|
33 | }
|
---|
34 |
|
---|
35 | char *kasprintf(gfp_t gfp, const char *fmt, ...)
|
---|
36 | {
|
---|
37 | va_list ap;
|
---|
38 | char *p;
|
---|
39 |
|
---|
40 | va_start(ap, fmt);
|
---|
41 | p = kvasprintf(gfp, fmt, ap);
|
---|
42 | va_end(ap);
|
---|
43 |
|
---|
44 | return p;
|
---|
45 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.