PipeWire 0.3.77
Loading...
Searching...
No Matches
spa/include/spa/debug/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
19#include <spa/debug/context.h>
20
21static inline int spa_debugc_mem(struct spa_debug_context *ctx, int indent, const void *data, size_t size)
22{
23 const uint8_t *t = (const uint8_t*)data;
24 char buffer[512];
25 size_t i;
26 int pos = 0;
27
28 for (i = 0; i < size; i++) {
29 if (i % 16 == 0)
30 pos = sprintf(buffer, "%p: ", &t[i]);
31 pos += sprintf(buffer + pos, "%02x ", t[i]);
32 if (i % 16 == 15 || i == size - 1) {
33 spa_debugc(ctx, "%*s" "%s", indent, "", buffer);
34 }
35 }
36 return 0;
37}
38
39static inline int spa_debug_mem(int indent, const void *data, size_t size)
40{
41 return spa_debugc_mem(NULL, indent, data, size);
42}
47#ifdef __cplusplus
48} /* extern "C" */
49#endif
50
51#endif /* SPA_DEBUG_MEM_H */
#define spa_debugc(_c, _fmt,...)
Definition: spa/include/spa/debug/context.h:37
static int spa_debug_mem(int indent, const void *data, size_t size)
Definition: spa/include/spa/debug/mem.h:44
static int spa_debugc_mem(struct spa_debug_context *ctx, int indent, const void *data, size_t size)
Definition: spa/include/spa/debug/mem.h:26
spa/debug/context.h
Definition: spa/include/spa/debug/context.h:33