Listing 2
#include <stdlib.h> #include <stdio.h> #include "safestr.h" #include "xxl.h" int main(int argc, char *argv[]) { safestr_t str1; safestr_t str2; XXL_TRY_BEGIN { str1 = safestr_alloc(12, 0); str2 = safestr_create("hello, world\n", 0); safestr_copy(&str1, str2); safestr_printf(str1); safestr_printf(str2); } XXL_CATCH (SAFESTR_ERROR_OUT_OF_MEMORY) { printf("safestr out of memory.\n"); } XXL_EXCEPT { printf("string operation failed.\n"); } XXL_TRY_END; return 0; }