Commit 3adbb41d authored by Rusty Russell's avatar Rusty Russell

talloc: fix examples so they compile.

parent 0f9074d0
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
* } * }
* *
* // This function opens a writable pipe to the given command. * // This function opens a writable pipe to the given command.
* struct command *open_output_cmd(const void *ctx, char *fmt, ...) * static struct command *open_output_cmd(const void *ctx, char *fmt, ...)
* { * {
* va_list ap; * va_list ap;
* struct command *cmd = talloc(ctx, struct command); * struct command *cmd = talloc(ctx, struct command);
......
...@@ -90,9 +90,9 @@ ...@@ -90,9 +90,9 @@
* is not affected by talloc_set_destructor(). * is not affected by talloc_set_destructor().
* *
* Example: * Example:
* unsigned int *a; * unsigned int *b, *a;
* a = talloc(NULL, unsigned int); * a = talloc(NULL, unsigned int);
* talloc_set(&b, a, unsigned int); * talloc_set(&b, a);
* talloc_free(a); * talloc_free(a);
* *b = 1; // This will crash! * *b = 1; // This will crash!
* *
...@@ -137,7 +137,7 @@ ...@@ -137,7 +137,7 @@
int talloc_free(const void *ptr); int talloc_free(const void *ptr);
/** /**
* talloc_set_destructor: set a destructor for when this pointer is freed * talloc_set_destructor - set a destructor for when this pointer is freed
* @ptr: the talloc pointer to set the destructor on * @ptr: the talloc pointer to set the destructor on
* @destructor: the function to be called * @destructor: the function to be called
* *
...@@ -170,7 +170,7 @@ int talloc_free(const void *ptr); ...@@ -170,7 +170,7 @@ int talloc_free(const void *ptr);
* return 0; * return 0;
* } * }
* *
* int *open_file(const char *filename) * static int *open_file(const char *filename)
* { * {
* int *fd = talloc(NULL, int); * int *fd = talloc(NULL, int);
* *fd = open(filename, O_RDONLY); * *fd = open(filename, O_RDONLY);
...@@ -246,6 +246,7 @@ int talloc_free(const void *ptr); ...@@ -246,6 +246,7 @@ int talloc_free(const void *ptr);
* *
* Example: * Example:
* void *mem = talloc_size(NULL, 100); * void *mem = talloc_size(NULL, 100);
* memset(mem, 0xFF, 100);
* *
* See Also: * See Also:
* talloc, talloc_array, talloc_zero_size * talloc, talloc_array, talloc_zero_size
...@@ -342,13 +343,13 @@ void talloc_report_full(const void *ptr, FILE *f); ...@@ -342,13 +343,13 @@ void talloc_report_full(const void *ptr, FILE *f);
* a = talloc(NULL, unsigned int); * a = talloc(NULL, unsigned int);
* b = talloc(NULL, unsigned int); * b = talloc(NULL, unsigned int);
* c = talloc(a, unsigned int); * c = talloc(a, unsigned int);
* // b also serves as a parent of c. * // b also serves as a parent of c (don't care about errors)
* talloc_reference(b, c); * (void)talloc_reference(b, c);
*/ */
#define talloc_reference(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_reference((ctx),(ptr)) #define talloc_reference(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_reference((ctx),(ptr))
/** /**
* talloc_unlink: remove a specific parent from a talloc pointer. * talloc_unlink - remove a specific parent from a talloc pointer.
* @context: the parent to remove * @context: the parent to remove
* @ptr: the talloc pointer * @ptr: the talloc pointer
* *
...@@ -363,13 +364,14 @@ void talloc_report_full(const void *ptr, FILE *f); ...@@ -363,13 +364,14 @@ void talloc_report_full(const void *ptr, FILE *f);
* Usually you can just use talloc_free() instead of talloc_unlink(), but * Usually you can just use talloc_free() instead of talloc_unlink(), but
* sometimes it is useful to have the additional control on which parent is * sometimes it is useful to have the additional control on which parent is
* removed. * removed.
*
* Example: * Example:
* unsigned int *a, *b, *c; * unsigned int *a, *b, *c;
* a = talloc(NULL, unsigned int); * a = talloc(NULL, unsigned int);
* b = talloc(NULL, unsigned int); * b = talloc(NULL, unsigned int);
* c = talloc(a, unsigned int); * c = talloc(a, unsigned int);
* // b also serves as a parent of c. * // b also serves as a parent of c.
* talloc_reference(b, c); * (void)talloc_reference(b, c);
* talloc_unlink(b, c); * talloc_unlink(b, c);
*/ */
int talloc_unlink(const void *context, void *ptr); int talloc_unlink(const void *context, void *ptr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment