+ +
2da5fe7 OpenAVX v0.2.0 - High-performance open-standard IP audio and video transport suite
saifmukhtar · 2026-11-24
main
| 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 | #include <inttypes.h> |
| 9 | |
| 10 | #include <spa/debug/context.h> |
| 11 | |
| 12 | #ifdef __cplusplus |
| 13 | extern "C" { |
| 14 | #endif |
| 15 | |
| 16 | /** |
| 17 | * \addtogroup spa_debug |
| 18 | * \{ |
| 19 | */ |
| 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 | } |
| 51 | /** |
| 52 | * \} |
| 53 | */ |
| 54 | |
| 55 | #ifdef __cplusplus |
| 56 | } /* extern "C" */ |
| 57 | #endif |
| 58 | |
| 59 | #endif /* SPA_DEBUG_MEM_H */ |