PipeWire: spa/debug/mem.h Source File

PipeWire 1.4.9

Loading...
Searching...
No Matches
mem.h
Go to the documentation of this file.
1/* Simple Plugin API */
2/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
3/* SPDX-License-Identifier: MIT */
4
5#ifndef SPA_DEBUG_MEM_H
6#define SPA_DEBUG_MEM_H
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12#include <inttypes.h>
13
18
19#include <spa/debug/context.h>
20
21#ifndef SPA_API_DEBUG_MEM
22 #ifdef SPA_API_IMPL
23 #define SPA_API_DEBUG_MEM SPA_API_IMPL
24 #else
25 #define SPA_API_DEBUG_MEM static inline
26 #endif
27#endif
28
29 SPA_API_DEBUG_MEM int spa_debugc_mem(struct spa_debug_context *ctx, int indent, const void *data, size_t size)
30{
31 const uint8_t *t = (const uint8_t*)data;
32 char buffer[512];
33 size_t i;
34 int pos = 0;
35
36 for (i = 0; i < size; i++) {
37 if (i % 16 == 0)
38 pos = sprintf(buffer, "%p: ", &t[i]);
39 pos += sprintf(buffer + pos, "%02x ", t[i]);
40 if (i % 16 == 15 || i == size - 1) {
41 spa_debugc(ctx, "%*s" "%s", indent, "", buffer);
42 }
43 }
44 return 0;
45}
46
47 SPA_API_DEBUG_MEM int spa_debug_mem(int indent, const void *data, size_t size)
48{
49 return spa_debugc_mem(NULL, indent, data, size);
50}
53
54
55#ifdef __cplusplus
56} /* extern "C" */
57#endif
58
59#endif /* SPA_DEBUG_MEM_H */
spa_debugc_mem
SPA_API_DEBUG_MEM int spa_debugc_mem(struct spa_debug_context *ctx, int indent, const void *data, size_t size)
Definition mem.h:36
spa_debugc
#define spa_debugc(_c, _fmt,...)
Definition context.h:49
spa_debug_mem
SPA_API_DEBUG_MEM int spa_debug_mem(int indent, const void *data, size_t size)
Definition mem.h:54
SPA_API_DEBUG_MEM
#define SPA_API_DEBUG_MEM
Definition mem.h:32
context.h
spa/debug/context.h
spa_debug_context
Definition context.h:45