The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/lib/kasprintf.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    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 
   13 /* Simplified asprintf. */
   14 char *kvasprintf(gfp_t gfp, const char *fmt, va_list ap)
   15 {
   16         unsigned int len;
   17         char *p;
   18         va_list aq;
   19 
   20         va_copy(aq, ap);
   21         len = vsnprintf(NULL, 0, fmt, aq);
   22         va_end(aq);
   23 
   24         p = kmalloc_track_caller(len+1, gfp);
   25         if (!p)
   26                 return NULL;
   27 
   28         vsnprintf(p, len+1, fmt, ap);
   29 
   30         return p;
   31 }
   32 EXPORT_SYMBOL(kvasprintf);
   33 
   34 char *kasprintf(gfp_t gfp, const char *fmt, ...)
   35 {
   36         va_list ap;
   37         char *p;
   38 
   39         va_start(ap, fmt);
   40         p = kvasprintf(gfp, fmt, ap);
   41         va_end(ap);
   42 
   43         return p;
   44 }
   45 EXPORT_SYMBOL(kasprintf);

Cache object: 85c452354754d53f4f82e7c5229ed763


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.