4 * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
28 #include "tizen-audio-internal.h"
30 /* ------ dump helper -------- */
31 #define MAX(a, b) ((a) > (b) ? (a) : (b))
33 dump_data_t* _audio_dump_new(int length)
35 dump_data_t* dump = NULL;
37 if ((dump = malloc(sizeof(dump_data_t)))) {
38 memset(dump, 0, sizeof(dump_data_t));
39 if ((dump->strbuf = malloc(length))) {
40 dump->p = &dump->strbuf[0];
51 void _audio_dump_add_str(dump_data_t *dump, const char *fmt, ...)
60 len = vsnprintf(dump->p, dump->left, fmt, ap);
63 dump->p += MAX(0, len);
64 dump->left -= MAX(0, len);
67 char* _audio_dump_get_str(dump_data_t *dump)
69 return (dump) ? dump->strbuf : NULL;
72 void _audio_dump_free(dump_data_t *dump)
80 /* ------ dump helper -------- */