1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
|
/* Copyright (C) 2020-2024 Philipp "ph3-der-loewe" Schafft <lion@lion.leolix.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef _LIBIGLOO__SP_H_
#define _LIBIGLOO__SP_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <igloo/types.h>
/* igloo_sp_ref() creates a new immutable reference to a immutable C string.
*
* igloo_sp_ref() creates a new reference by any mean it sees fit, including
* creating a copy and deduplication.
* The newly created reference will stay valid until igloo_sp_unref() is called,
* that is even if the string it is created from becomes invalid.
*
* NOTE:
* This has been deprecated! Use igloo_sp_replace().
*
* Parameters:
* str
* The string to create a reference to. This can be a reference itself.
* ref
* Pointer to where to store the newly created reference.
* instance
* The instance to use. This instance must stay valid until igloo_sp_unref()
* is called on the newly created reference.
* Returns:
* The error code for the operation.
*/
igloo_error_t igloo_sp_ref(const char *str, const char **ref, igloo_ro_t instance) igloo_ATTR_F_WARN_UNUSED_RESULT igloo_ATTR_F_DEPRECATED("Use igloo_sp_replace()");
/* igloo_sp_replace() creates a new immutable reference to a immutable C string.
*
* igloo_sp_replace() creates a new reference by any mean it sees fit, including
* creating a copy and deduplication.
* The newly created reference will stay valid until igloo_sp_unref() is called,
* that is even if the string it is created from becomes invalid.
*
* Parameters:
* str
* The string to create a reference to. This can be a reference itself.
* If NULL *ref will also be set to NULL.
* ref
* Pointer to where to store the newly created reference.
* If *ref is not NULL igloo_sp_unref() will be called on it.
* This happens in a safe manner, so that igloo_sp_unref() is only called
* if this returns igloo_ERROR_NONE.
* instance
* The instance to use. This instance must stay valid until igloo_sp_unref()
* is called on the newly created reference.
* Returns:
* The error code for the operation.
*/
igloo_error_t igloo_sp_replace(const char *str, const char **ref, igloo_ro_t instance) igloo_ATTR_F_WARN_UNUSED_RESULT;
/* Frees a reference to a string.
* Parameters:
* ref
* Pointer to the reference as created by igloo_sp_ref().
* instance
* The instance used for igloo_sp_ref().
* Returns:
* The error code for the operation.
*/
igloo_error_t igloo_sp_unref(const char **ref, igloo_ro_t instance) igloo_ATTR_F_WARN_UNUSED_RESULT;
#ifdef __cplusplus
}
#endif
#endif /* ! _LIBIGLOO__SP_H_ */
|