cstring · Section 3
cstr_construct_scoped
NAME
cstr_construct_scoped - declare and initialise a cstr with automatic RAII
LIBRARY
C Collections (libccollections, -lccollections)
SYNOPSIS
#include <ccollections/cstring.h> cstr_construct_scoped(s, initial);
DESCRIPTION
This macro does cstr_declare_scoped() and cstr_init() in one statement, and the string is destroyed automatically when the variable leaves its scope.
PARAMETERS
s Variable name to create initial Initial content (C string or NULL for empty string)
NOTES
This macro needs GCC or Clang, because it uses __attribute__((cleanup))
EXAMPLES
{
cstr_construct_scoped(s, "auto-freed");
/* use s ... */
} /* the program destroys s here automatically */