This is common.c in view mode; [Download] [Up]
/***********************************************************************
Common c code for Convert programs
Copyright (C) 1993 David John Burrowes
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author, David John Burrowes, can be reached at:
davidjohn@kira.net.netcom.com
David John Burrowes
1926 Ivy #10
San Mateo, CA 94403-1367
***********************************************************************/
#import "common.h"
#import <stdlib.h>
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// This function takes an unsigned number, and returns YES if the number is
// even, and NO otherwise.
// This test is accomplished simply by getting the remainder of dividing the number
// by 2. This remainder will always be either 0 or 1. If it is 1, then theNum was
// odd, otherwise it was even.
// This function is included here because this is occasionally a thing I need to make
// use of, but alas I always end up spending too much time remembering the operators
// needed to do it again.
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Boolean EvenUnsignedNum (PositiveInteger theNum)
{
if ((theNum % 2) == 1)
return NO;
else
return YES;
}
CString NewCString(PositiveInteger length)
{
CString temp = (CString) malloc(length+1);
temp[0] = EndOfCString;
return temp;
}
void FreeCString(CString theString)
{
free((char*)theString);
}
ByteString NewByteString(PositiveInteger length)
{
return (ByteString) malloc(length);
}
void FreeByteString(ByteString theString)
{
free((char*)theString);
}
Pointer NewPointer(PositiveInteger length)
{
return (Pointer) malloc(length);
}
void FreePointer(Pointer thePointer)
{
free((char*)thePointer);
}
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.