Edit

kc3-lang/libxkbcommon/src/util-mem.h

Branch :

  • Show log

    Commit

  • Author : Pierre Le Marre
    Date : 2025-07-07 12:28:24
    Hash : dc63e5f8
    Message : Ensure config.h is always included first While `config.h` may not be necessary in every file, it ensures consistency and makes code refactoring safer.

  • src/util-mem.h
  • /*
     * Copyright © 2020 Red Hat, Inc.
     * SPDX-License-Identifier: MIT
     */
    
    #pragma once
    
    #include "config.h"
    
    #include <stdlib.h>
    
    static inline void*
    _steal(void *ptr) {
        void **original = (void**)ptr;
        void *swapped = *original;
        *original = NULL;
        return swapped;
    }
    
    /**
     * Resets the pointer content and resets the data to NULL.
     */
    #ifdef _WIN32
    #define steal(ptr_) \
        _steal(ptr_)
    #else
    #define steal(ptr_) \
        (__typeof__(*(ptr_)))_steal(ptr_)
    #endif