diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2007-03-23 16:06:22 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2007-03-23 16:06:22 +0000 |
commit | fb18a14fa419ea6627fa1f148bd1a479cd53639b (patch) | |
tree | 5fdfe02f401872922d56c1fadf93019edd45f3b7 /nuttx/examples/ostest/cancel.c | |
parent | f4a63abc585084602a4af8f70367178e8c511337 (diff) | |
download | nuttx-fb18a14fa419ea6627fa1f148bd1a479cd53639b.tar.gz nuttx-fb18a14fa419ea6627fa1f148bd1a479cd53639b.tar.bz2 nuttx-fb18a14fa419ea6627fa1f148bd1a479cd53639b.zip |
Fix memory leaks
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@133 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/examples/ostest/cancel.c')
-rw-r--r-- | nuttx/examples/ostest/cancel.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/nuttx/examples/ostest/cancel.c b/nuttx/examples/ostest/cancel.c index 2bd08da24..4af1b86fb 100644 --- a/nuttx/examples/ostest/cancel.c +++ b/nuttx/examples/ostest/cancel.c @@ -202,7 +202,9 @@ void cancel_test(void) printf("cancel_test: ERROR pthread_cancel failed, status=%d\n", status); } - /* Then join to the thread to pick up the result */ + /* Then join to the thread to pick up the result (if we don't do + * we will have a memory leak!) + */ printf("cancel_test: Joining\n"); status = pthread_join(waiter, &result); @@ -283,7 +285,7 @@ void cancel_test(void) printf("cancel_test: ERROR pthread_cancel failed, status=%d\n", status); } - /* Signal the thread. It should wake up an restore the cancelable state. + /* Signal the thread. It should wake up and restore the cancelable state. * When the cancelable state is re-enabled, the thread should be canceled. */ @@ -304,4 +306,28 @@ void cancel_test(void) { printf("cancel_test: ERROR pthread_mutex_unlock failed, status=%d\n", status); } + + /* Then join to the thread to pick up the result (if we don't do + * we will have a memory leak!) + */ + + printf("cancel_test: Joining\n"); + status = pthread_join(waiter, &result); + if (status != 0) + { + printf("cancel_test: ERROR pthread_join failed, status=%d\n", status); + } + else + { + printf("cancel_test: waiter exited with result=%p\n", result); + if (result != PTHREAD_CANCELED) + { + printf("cancel_test: ERROR expected result=%p\n", PTHREAD_CANCELED); + } + else + { + printf("cancel_test: PASS thread terminated with PTHREAD_CANCELED\n"); + } + } + } |