Skip to content

Commit

Permalink
it works! now i am dealing with memory management issues
Browse files Browse the repository at this point in the history
  • Loading branch information
schacon committed Sep 29, 2008
1 parent a180c99 commit e03ce94
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 26 deletions.
7 changes: 4 additions & 3 deletions AppController.m
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ - (void) applicationDidFinishLaunching:(UIApplication*)application

- (void) dealloc
{
NSLog(@"dealloc");
[_inStream removeFromRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
[_inStream release];

Expand Down Expand Up @@ -128,6 +129,8 @@ - (void) setup {
[self _showAlert:@"Failed advertising server"];
return;
}


}

- (void) send:(const uint8_t)message
Expand Down Expand Up @@ -171,9 +174,6 @@ - (void) stream:(NSStream*)stream handleEvent:(NSStreamEvent)eventCode
switch(eventCode) {
case NSStreamEventOpenCompleted:
{
[_server release];
_server = nil;

if (stream == _inStream)
_inReady = YES;
else
Expand Down Expand Up @@ -209,6 +209,7 @@ @implementation AppController (TCPServerDelegate)

- (void) serverDidEnableBonjour:(TCPServer*)server withName:(NSString*)string
{
NSLog(@"testtest");
NSLog(@"%s", _cmd);
}

Expand Down
1 change: 0 additions & 1 deletion Git/ObjGit.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
- (BOOL) ensureGitPath;
- (void) initGitRepo;
- (NSArray *) getAllRefs;
- (NSString *) getName;

- (NSString *) writeObject:(NSData *)objectData withType:(NSString *)type withSize:(int)size;
- (void) updateRef:(NSString *)refName toSha:(NSString *)toSha;
Expand Down
15 changes: 5 additions & 10 deletions Git/ObjGit.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@ - (void) dealloc
[super dealloc];
}

- (NSString *) getName
{
NSLog(@"GIT NAME TEST");
NSLog(@"GIT NAME:%@", self.gitName);
return self.gitName;
}

- (BOOL) ensureGitPath {
BOOL isDir;
NSFileManager *fm = [NSFileManager defaultManager];
Expand Down Expand Up @@ -155,16 +148,18 @@ - (NSMutableArray *) getCommitsFromSha:(NSString *)shaValue withLimit:(int)commi
}

// NSLog(@"s: %@", commitArray);

//[toDoArray release];
return commitArray;
}

- (ObjGitObject *) getObjectFromSha:(NSString *)sha1
{
NSString *objectPath = [self getLooseObjectPathBySha:sha1];
NSLog(@"READ FROM FILE: %@", objectPath);
//NSLog(@"READ FROM FILE: %@", objectPath);
NSFileHandle *fm = [NSFileHandle fileHandleForReadingAtPath:objectPath];
return [[ObjGitObject alloc] initFromRaw:[fm availableData] withSha:sha1];
ObjGitObject *obj = [[ObjGitObject alloc] initFromRaw:[fm availableData] withSha:sha1];
[fm closeFile];
return obj;
}

- (BOOL) hasObject: (NSString *)sha1
Expand Down
10 changes: 8 additions & 2 deletions Git/ObjGitServerHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,11 @@ - (void) gatherObjectShasFromCommit:(NSString *)shaValue

- (void) gatherObjectShasFromTree:(NSString *)shaValue
{
ObjGitTree *tree = [[ObjGitTree alloc] initFromGitObject:[gitRepo getObjectFromSha:shaValue]];
ObjGitTree *tree = [ObjGitTree alloc];
[tree initFromGitObject:[gitRepo getObjectFromSha:shaValue]];
[refDict setObject:@"/" forKey:shaValue];
NSEnumerator *e = [[tree treeEntries] objectEnumerator];
//[tree release];
NSArray *entries;
NSString *name, *sha, *mode;
while ( (entries = [e nextObject]) ) {
Expand Down Expand Up @@ -419,6 +421,7 @@ - (void) unpackDeltified:(int)type size:(int)size {
contents = [self patchDelta:objectData withObject:object];
//NSLog(@"unpacked delta: %@ : %@", contents, [object type]);
[gitRepo writeObject:contents withType:[object type] withSize:[contents length]];
//[object release];
} else {
// TODO : OBJECT ISN'T HERE YET, SAVE THIS DELTA FOR LATER //
/*
Expand Down Expand Up @@ -510,10 +513,13 @@ - (NSData *) patchDelta:(NSData *)deltaData withObject:(ObjGitObject *)gitObject
[destination appendBytes:[buffer bytes] length:cp_size];
//NSLog(@"dest: %@", destination);
} else if(c[0] != 0) {
if(c[0] > destSize)
break;
//NSLog(@"thingy: %d, %d", position, c[0]);
[source getBytes:[buffer mutableBytes] range:NSMakeRange(position, c[0])];
[deltaData getBytes:[buffer mutableBytes] range:NSMakeRange(position, c[0])];
[destination appendBytes:[buffer bytes] length:c[0]];
position += c[0];
destSize -= c[0];
} else {
NSLog(@"invalid delta data");
}
Expand Down
2 changes: 1 addition & 1 deletion Git/ObjGitTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
ObjGitObject *gitObject;
}

@property(assign, readwrite) NSArray *treeEntries;
@property(copy, readwrite) NSArray *treeEntries;
@property(assign, readwrite) ObjGitObject *gitObject;

- (id) initFromGitObject:(ObjGitObject *)object;
Expand Down
8 changes: 3 additions & 5 deletions Git/ObjGitTree.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ @implementation ObjGitTree
@synthesize gitObject;

- (id) initFromGitObject:(ObjGitObject *)object {
NSLog(@"Tree init1");
self = [super init];
NSLog(@"Tree init");
gitObject = object;
self.gitObject = object;
[self parseContent];
return self;
}
Expand All @@ -29,7 +27,7 @@ - (void) logObject
// 100644 testfile\0[20 char sha]
- (void) parseContent
{
char *contents = [gitObject rawContents];
char *contents = [self.gitObject rawContents];

char mode[9];
int modePtr = 0;
Expand All @@ -46,7 +44,7 @@ - (void) parseContent
int i, j, state;
state = 1;

for(i = 0; i < [gitObject rawContentLen] - 1; i++) {
for(i = 0; i < [self.gitObject rawContentLen] - 1; i++) {
if(contents[i] == 0) {
state = 1;
for(j = 0; j < 20; j++)
Expand Down
4 changes: 0 additions & 4 deletions ProjectViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
}

// Get the object to display and set the value in the cell
NSLog(@"TEST 1");
NSLog(@"OBJ:%@", [projectController objectInListAtIndex:indexPath.row]);
ObjGit *itemAtIndex = [projectController objectInListAtIndex:indexPath.row];
NSLog(@"TEST 2");
NSLog(@"obj:%@", [itemAtIndex getName]);
cell.text = [itemAtIndex gitName];
return cell;
}
Expand Down

0 comments on commit e03ce94

Please sign in to comment.