This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// task_for_pid leak | |
// **IMPORTANT** To reproduce this bug, you have to sign this program with a developer ID -- do not use a self-signed certificate or run as root! | |
// This code will cause taskgated's memory usage to grow (see activity monitor) | |
// Link to Xcode project with included info.plist: http://tinyurl.com/kps28av | |
// Radar 16230826 | |
#include <mach/mach_init.h> | |
#include <mach/task.h> | |
#include <mach/mach_port.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "ZZGAppDelegate.h" | |
@interface Foo : NSObject | |
@end | |
@implementation Foo | |
- (void)dealloc | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function xman | |
set lookup_name "$argv[-1]" | |
set lookup_section "$argv[1]" | |
set open_string "" | |
set grep_string "" | |
set beginning_pattern "(^|[ \t\r\n\f])" | |
if [ $lookup_name = $lookup_section ]; set open_string "x-man-page://$lookup_name"; set grep_string "$beginning_pattern$lookup_name\\("; end; | |
if [ $lookup_name != $lookup_section ]; set open_string "x-man-page://$lookup_section/$lookup_name"; set grep_string "$beginning_pattern$lookup_name\\($lookup_section\\)"; end; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cargo rustc --release -- -C no-stack-check -C target-cpu=native --emit llvm-ir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@protocol M | |
@end | |
NSArray<M, NSValue *, NSURL, NSArray <id <M>>> *foo = @[@"a"]; | |
NSNumber *bar = foo[0]; | |
NSLog(@"%@", bar); | |
// No warnings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Note that on the command line cp -R /Volumes/mayur/bar.txt /Users/msp/Desktop/bar.txt | |
// works just fine; the symbolic link is copied, and it's not followed | |
// But I have *no idea* how to do this programatically as shown below | |
// (Note: My end goal is being able to copy an app from a volume to my local disk, but | |
// it fails when it encounters a symbolic link) | |
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { | |
NSURL *sourceURL = [NSURL fileURLWithPath:@"/Volumes/mayur/bar.txt"]; // this is a symbolic link | |
NSURL *destinationURL = [NSURL fileURLWithPath:@"/Users/msp/Desktop/bar.txt"]; | |
// this outputs 1, so the source does exist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename T, typename P> | |
void ZGSearchWithFunctionHelperDirect(T *searchValue, bool (*comparisonFunction)(ZGSearchData *, T *, T *), ZGSearchData * __unsafe_unretained searchData, ZGMemorySize dataIndex, ZGMemorySize dataSize, ZGMemorySize dataAlignment, ZGMemorySize endLimit, P pointerSize, NSMutableData * __unsafe_unretained resultSet, ZGMemoryAddress address, void *bytes) | |
{ | |
//dataIndex is 'position' in the data, endLimit is (region_size) - (datatype_size) | |
//dataAlignment is amount to advance dataIndex for each iteration | |
while (dataIndex <= endLimit) | |
{ | |
if (comparisonFunction(searchData, (T *)((int8_t *)bytes + dataIndex), searchValue)) | |
{ | |
P memoryAddress = (P)(address + dataIndex); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename T, typename P> | |
void ZGSearchWithFunctionHelperDirect(T *searchValue, bool (*comparisonFunction)(ZGSearchData *, T *, T *), ZGSearchData * __unsafe_unretained searchData, ZGMemorySize dataIndex, ZGMemorySize dataSize, ZGMemorySize dataAlignment, ZGMemorySize endLimit, P pointerSize, NSMutableData * __unsafe_unretained resultSet, ZGMemoryAddress address, void *bytes) | |
{ | |
ZGMemorySize maxSteps = 4096; | |
while (dataIndex <= endLimit) | |
{ | |
ZGMemorySize numberOfVariablesFound = 0; | |
P memoryAddresses[maxSteps]; | |
for (ZGMemorySize stepIndex = 0; stepIndex < maxSteps && dataIndex <= endLimit; stepIndex++) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename T, typename P> | |
void ZGSearchWithFunctionHelperRegular(T *searchValue, bool (*comparisonFunction)(ZGSearchData *, T *, T *), ZGSearchData * __unsafe_unretained searchData, ZGMemorySize dataIndex, ZGMemorySize dataAlignment, ZGMemorySize endLimit, P pointerSize, NSMutableData * __unsafe_unretained resultSet, ZGMemoryAddress address, void *bytes) | |
{ | |
const ZGMemorySize maxSteps = 4096; | |
while (dataIndex <= endLimit) | |
{ | |
ZGMemorySize numberOfVariablesFound = 0; | |
P memoryAddresses[maxSteps]; | |
ZGMemorySize numberOfStepsToTake = MIN(maxSteps, (endLimit + dataAlignment - dataIndex) / dataAlignment); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "ZGAppDelegate.h" | |
@interface ZGAppDelegate () | |
@property (nonatomic) NSTimer *timer; | |
@property (assign) IBOutlet NSProgressIndicator *progressIndicator; | |
@end | |
@implementation ZGAppDelegate |
OlderNewer