| // Copyright 2013 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| /* Test calling panic from C. This is what SWIG does. */ |
| extern void _cgo_panic(const char *); |
| extern void *_cgo_allocate(size_t); |
| _cgo_panic("panic from C"); |
| /* Test calling cgo_allocate from C. This is what SWIG does. */ |
| typedef struct List List; |
| // Make sure this doesn't crash. |
| // And make sure it returns non-nil. |
| if(_cgo_allocate(0) == 0) { |
| fprintf(stderr, "callCgoAllocate: alloc 0 returned nil\n"); |
| l = _cgo_allocate(sizeof *l); |
| fprintf(stderr, "callCgoAllocate: lost memory\n"); |
| fprintf(stderr, "callCgoAllocate: lost memory\n"); |