Change 14587: Check ownership of CatInfos (MacPerl Bug #494482)

[email protected] (Chris Nandor) Thu, 7 Feb 2002 16:39:11 -0500
Newsgroups perl.perl5.changes.mac
Message-ID <p05100308b888a4680d0f@[10.0.1.177]>
Change 14587 by pudge@pudge-mobile on 2002/02/07 18:46:28

	Check ownership of CatInfos (MacPerl Bug #494482)

Affected files ...

.... //depot/maint-5.6/macperl/macos/ext/Mac/Files/Files.xs#3 edit

Differences ...

==== //depot/maint-5.6/macperl/macos/ext/Mac/Files/Files.xs#3 (text) ====
Index: perl/macos/ext/Mac/Files/Files.xs
--- perl/macos/ext/Mac/Files/Files.xs.~1~	Thu Feb  7 12:00:05 2002
+++ perl/macos/ext/Mac/Files/Files.xs	Thu Feb  7 12:00:05 2002
@@ -1,4 +1,4 @@
-/* $Header: /cvsroot/macperl/perl/macos/ext/Mac/Files/Files.xs,v 1.4 2002/01/23 05:44:42 pudge Exp $
+/* $Header: /cvsroot/macperl/perl/macos/ext/Mac/Files/Files.xs,v 1.5 2002/01/30 07:43:54 neeri Exp $
  *
  *    Copyright (c) 1996 Matthias Neeracher
  *
@@ -6,6 +6,9 @@
  *    as specified in the README file.
  *
  * $Log: Files.xs,v $
+ * Revision 1.5  2002/01/30 07:43:54  neeri
+ * Check ownership of CatInfos
+ *
  * Revision 1.4  2002/01/23 05:44:42  pudge
  * Update whitespace etc., from Thomas
  *
@@ -48,16 +51,24 @@
 #include <Errors.h>
 #include <Aliases.h>
 
+#define MACPERL_CATINFO	'MpCI'
+
 typedef FSSpec			RealFSSpec;
 typedef CInfoPBPtr 	CatInfo;
+typedef struct {
+	CInfoPBRec	fInfo;
+	OSType		fOwner;
+	Str63		fName;
+} ExtCatInfo;
 
 static CatInfo NewCatInfo()
 {
-	CatInfo	ci;
-	ci = (CatInfo) malloc(sizeof(CInfoPBRec)+sizeof(Str63));
-	ci->hFileInfo.ioNamePtr = (StringPtr) ((char *)ci+sizeof(CInfoPBRec));
+	ExtCatInfo*	ci;
+	ci = (ExtCatInfo *) malloc(sizeof(ExtCatInfo));
+	ci->fOwner	= MACPERL_CATINFO;
+	ci->fInfo.hFileInfo.ioNamePtr = ci->fName;
 	
-	return ci;
+	return (CatInfo)ci;
 }
 
 MODULE = Mac::Files	PACKAGE = Mac::Files
@@ -214,7 +225,8 @@
 DESTROY(cat)
 	CatInfo	cat
 	CODE:
-	free(cat);
+	if (((ExtCatInfo *)cat)->fOwner == MACPERL_CATINFO)
+		free(cat);
 
 
 MODULE = Mac::Files	PACKAGE = Mac::Files
End of Patch.