mirror of
https://github.com/sigmasternchen/libargo
synced 2025-03-15 21:28: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("User.Email: %s\n", post->user.email);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
|
free(post->content);
|
||||||
post->content = "Just do it.";
|
post->content = "Just do it.";
|
||||||
|
|
||||||
char* newJson = json_marshall(post_t, post);
|
char* newJson = json_marshall(post_t, post);
|
||||||
printf("%s\n", newJson);
|
printf("%s\n", newJson);
|
||||||
|
|
||||||
free(newJson);
|
free(newJson);
|
||||||
|
|
||||||
|
// set to NULL so it doesn't get freed
|
||||||
|
post->content = NULL;
|
||||||
|
json_free_struct(post_t, post);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,13 +4,13 @@
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
long long uid;
|
long long uid;
|
||||||
const char* username;
|
char* username;
|
||||||
const char* email;
|
char* email;
|
||||||
} user_t;
|
} user_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char* name;
|
char* name;
|
||||||
const char* content;
|
char* content;
|
||||||
long* views;
|
long* views;
|
||||||
user_t user;
|
user_t user;
|
||||||
} post_t;
|
} post_t;
|
||||||
|
|
Loading…
Reference in a new issue