1/* 2 * Copyright (c) 2010 Apple Inc. All rights reserved. 3 * 4 * @APPLE_LLVM_LICENSE_HEADER@ 5 */ 6 7/* 8 * byrefcopyint.c 9 * testObjects 10 * 11 * Created by Blaine Garst on 12/1/08. 12 * Copyright 2008 __MyCompanyName__. All rights reserved. 13 * 14 */ 15 16// 17// byrefcopyid.m 18// testObjects 19// 20// Created by Blaine Garst on 5/13/08. 21// Copyright 2008 __MyCompanyName__. All rights reserved. 22// 23 24// TEST_CONFIG 25 26// Tests copying of blocks with byref ints 27// rdar://6414583 28 29#include <stdio.h> 30#include <string.h> 31#include <Block.h> 32#include <Block_private.h> 33#include "test.h" 34 35typedef void (^voidVoid)(void); 36 37voidVoid dummy; 38 39void callVoidVoid(voidVoid closure) { 40 closure(); 41} 42 43 44voidVoid testRoutine(const char *whoami) { 45 __block size_t dumbo = strlen(whoami); 46 dummy = ^{ 47 //printf("incring dumbo from %d\n", dumbo); 48 ++dumbo; 49 }; 50 51 52 voidVoid copy = Block_copy(dummy); 53 54 55 return copy; 56} 57 58int main(int argc __unused, char *argv[]) { 59 voidVoid array[100]; 60 for (int i = 0; i < 100; ++i) { 61 array[i] = testRoutine(argv[0]); 62 array[i](); 63 } 64 for (int i = 0; i < 100; ++i) { 65 Block_release(array[i]); 66 } 67 68 succeed(__FILE__); 69} 70