PipeWire: spa/debug/mem.h Source File

PipeWire 1.2.3

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
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 */
spa_debugc
#define spa_debugc(_c, _fmt,...)
Definition context.h:38
spa_debug_mem
static int spa_debug_mem(int indent, const void *data, size_t size)
Definition mem.h:44
spa_debugc_mem
static int spa_debugc_mem(struct spa_debug_context *ctx, int indent, const void *data, size_t size)
Definition mem.h:26
context.h
spa/debug/context.h
spa_debug_context
Definition context.h:34