diff options
| author | SND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2012-10-19 23:14:07 +0000 |
|---|---|---|
| committer | SND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2012-10-19 23:14:07 +0000 |
| commit | 055fff5071b4fdfb11886a723f56d51fadfd8c9d (patch) | |
| tree | 366ad501bfdfefc041622147c47bc2c07849dc87 /macosx/plugins/DFXVideo/macsrc/PluginGLView.m | |
| parent | 0572e4bfc3df76bfacbd6c0853857a53ee793c50 (diff) | |
| download | pcsxr-055fff5071b4fdfb11886a723f56d51fadfd8c9d.tar.gz | |
Allocate the buffer in loadSource via length of the data and not the file size. This means technically a web URL could be passed to it and it would still work.
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@80642 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'macosx/plugins/DFXVideo/macsrc/PluginGLView.m')
| -rw-r--r-- | macosx/plugins/DFXVideo/macsrc/PluginGLView.m | 56 |
1 files changed, 2 insertions, 54 deletions
diff --git a/macosx/plugins/DFXVideo/macsrc/PluginGLView.m b/macosx/plugins/DFXVideo/macsrc/PluginGLView.m index 8f5f4a6b..8f6f3802 100644 --- a/macosx/plugins/DFXVideo/macsrc/PluginGLView.m +++ b/macosx/plugins/DFXVideo/macsrc/PluginGLView.m @@ -838,66 +838,14 @@ void BlitScreen16NS(unsigned char * surf,long x,long y) - (char*)loadSource:(NSURL *)filename { - /*char *src = NULL; - FILE *fp = NULL; - long size; - long i; - - - // Open the file - fp = fopen(filename, "r"); - // Check if its OK - if(fp == NULL) - { - fprintf(stderr, "Impossible to open the file '%s'\n", filename); - return NULL; - } - - // Get the file size - fseek(fp, 0, SEEK_END); - size = ftell(fp); - - // Go back to the beginning - rewind(fp); - - // Allocate memory - src = malloc(size+1); // +1 for '\0' - if(src == NULL) - { - fclose(fp); - fprintf(stderr, "Memory allocation error!\n"); - return NULL; - } - - // The the file - for(i=0; i<size; i++) - src[i] = fgetc(fp); - - // Put the last char as '\0' - src[size] = '\0'; - - fclose(fp); - - return src;*/ - //NSURL *actualFile = [filename filePathURL]; //Since we're passing Cocoa NSURLs, let's use Cocoa's methods if (filename == nil) { return NULL; } - NSNumber *filesizeAsNS = nil; - long long filesize = 0; - [filename getResourceValue:&filesizeAsNS forKey:NSURLFileSizeKey error:nil]; - if (filesizeAsNS == nil) { - return NULL; - } - filesize = [filesizeAsNS longLongValue]; - if (filesize == 0) { - return NULL; - } NSMutableData *shaderData = [NSMutableData dataWithContentsOfURL:filename]; [shaderData appendBytes:"\0" length:1]; - char *shaderText = malloc(filesize + 1); - memcpy(shaderText, [shaderData bytes], filesize + 1); + char *shaderText = malloc([shaderData length]); + memcpy(shaderText, [shaderData bytes], [shaderData length]); return shaderText; } |
