You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

28 lines
642 B

#include "libc99.h"
#include <stdlib.h>
#include <string.h>
Test_struct1* new_test_struct(int c_int, Test_enum c_enum, const char* c_str)
{
Test_struct1* result = calloc(1, sizeof(Test_struct1));
if (result) {
result->c_int = c_int;
result->c_enum = c_enum;
if (c_str) {
result->c_str = strdup(c_str);
if (result->c_str == NULL) {
free_test_struct(result);
return NULL;
}
}
}
return result;
}
void free_test_struct(Test_struct1* c_struct)
{
if (c_struct) {
free(c_struct->c_str);
free(c_struct);
}
}