Bumping manifests a=b2g-bump
[gecko.git] / js / src / jsprf.h
blobe8c9b6d27e0aa3cdcd4b5564c57ae341ab6ff714
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * vim: set ts=8 sts=4 et sw=4 tw=99:
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef jsprf_h
8 #define jsprf_h
11 ** API for PR printf like routines. Supports the following formats
12 ** %d - decimal
13 ** %u - unsigned decimal
14 ** %x - unsigned hex
15 ** %X - unsigned uppercase hex
16 ** %o - unsigned octal
17 ** %hd, %hu, %hx, %hX, %ho - 16-bit versions of above
18 ** %ld, %lu, %lx, %lX, %lo - 32-bit versions of above
19 ** %lld, %llu, %llx, %llX, %llo - 64 bit versions of above
20 ** %s - ascii string
21 ** %hs - ucs2 string
22 ** %c - character
23 ** %p - pointer (deals with machine dependent pointer size)
24 ** %f - float
25 ** %g - float
28 #include <stdarg.h>
30 #include "jstypes.h"
33 ** sprintf into a fixed size buffer. Guarantees that a NUL is at the end
34 ** of the buffer. Returns the length of the written output, NOT including
35 ** the NUL, or (uint32_t)-1 if an error occurs.
37 extern JS_PUBLIC_API(uint32_t) JS_snprintf(char* out, uint32_t outlen, const char* fmt, ...);
40 ** sprintf into a malloc'd buffer. Return a pointer to the malloc'd
41 ** buffer on success, nullptr on failure. Call "JS_smprintf_free" to release
42 ** the memory returned.
44 extern JS_PUBLIC_API(char*) JS_smprintf(const char* fmt, ...);
47 ** Free the memory allocated, for the caller, by JS_smprintf
49 extern JS_PUBLIC_API(void) JS_smprintf_free(char* mem);
52 ** "append" sprintf into a malloc'd buffer. "last" is the last value of
53 ** the malloc'd buffer. sprintf will append data to the end of last,
54 ** growing it as necessary using realloc. If last is nullptr, JS_sprintf_append
55 ** will allocate the initial string. The return value is the new value of
56 ** last for subsequent calls, or nullptr if there is a malloc failure.
58 extern JS_PUBLIC_API(char*) JS_sprintf_append(char* last, const char* fmt, ...);
61 ** va_list forms of the above.
63 extern JS_PUBLIC_API(uint32_t) JS_vsnprintf(char* out, uint32_t outlen, const char* fmt, va_list ap);
64 extern JS_PUBLIC_API(char*) JS_vsmprintf(const char* fmt, va_list ap);
65 extern JS_PUBLIC_API(char*) JS_vsprintf_append(char* last, const char* fmt, va_list ap);
67 #endif /* jsprf_h */