mirror of
https://github.com/sigmasternchen/libargo
synced 2025-03-15 05:08:54 +00:00
fixes demo to show how to free the resources
This commit is contained in:
parent
fcf69c17c8
commit
7590a1acd7
2 changed files with 9 additions and 5 deletions
|
@ -29,12 +29,16 @@ int main() {
|
|||
printf("User.Email: %s\n", post->user.email);
|
||||
printf("\n");
|
||||
|
||||
free(post->content);
|
||||
post->content = "Just do it.";
|
||||
|
||||
char* newJson = json_marshall(post_t, post);
|
||||
printf("%s\n", newJson);
|
||||
|
||||
free(newJson);
|
||||
|
||||
// set to NULL so it doesn't get freed
|
||||
post->content = NULL;
|
||||
json_free_struct(post_t, post);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -4,13 +4,13 @@
|
|||
|
||||
typedef struct {
|
||||
long long uid;
|
||||
const char* username;
|
||||
const char* email;
|
||||
char* username;
|
||||
char* email;
|
||||
} user_t;
|
||||
|
||||
typedef struct {
|
||||
const char* name;
|
||||
const char* content;
|
||||
char* name;
|
||||
char* content;
|
||||
long* views;
|
||||
user_t user;
|
||||
} post_t;
|
||||
|
|
Loading…
Reference in a new issue