forked from dotnet/corefx
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpal_string.cpp
More file actions
36 lines (30 loc) · 902 Bytes
/
pal_string.cpp
File metadata and controls
36 lines (30 loc) · 902 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
#include "pal_config.h"
#include "pal_string.h"
#include "pal_utilities.h"
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
extern "C" int32_t SNPrintF(char* string, int32_t size, const char* format, ...)
{
assert(string != nullptr || size == 0);
assert(size >= 0);
assert(format != nullptr);
if (size < 0)
return -1;
va_list arguments;
va_start(arguments, format);
int result = vsnprintf(string, UnsignedCast(size), format, arguments);
va_end(arguments);
return result;
}
extern "C" int32_t PrintF(const char* format, ...)
{
va_list arguments;
va_start(arguments, format);
int result = vprintf(format, arguments);
va_end(arguments);
return result;
}