Merge pull request #10723 from prednaz/embedding_the_nix_evaluator_example

fix "Embedding the Nix Evaluator" c api example
This commit is contained in:
Eelco Dolstra 2024-05-16 10:14:21 +02:00 committed by GitHub
commit ba2911b03b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -46,9 +46,9 @@ Nix expression `builtins.nixVersion`.
// NOTE: This example lacks all error handling. Production code must check for // NOTE: This example lacks all error handling. Production code must check for
// errors, as some return values will be undefined. // errors, as some return values will be undefined.
void my_get_string_cb(const char * start, unsigned int n, char ** user_data) void my_get_string_cb(const char * start, unsigned int n, void * user_data)
{ {
*user_data = strdup(start); *((char **) user_data) = strdup(start);
} }
int main() int main()
@ -63,7 +63,7 @@ int main()
nix_value_force(NULL, state, value); nix_value_force(NULL, state, value);
char * version; char * version;
nix_get_string(NULL, value, my_get_string_cb, version); nix_get_string(NULL, value, my_get_string_cb, &version);
printf("Nix version: %s\n", version); printf("Nix version: %s\n", version);
free(version); free(version);