Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
HTArray.c
Package: arena-beta-2b-src.tar.gz [view]
Upload User: zlh9724
Upload Date: 2007-01-04
Package Size: 1991k
Code Size: 2k
Category:
Browser Client
Development Platform:
Unix_Linux
- /* HTArray.c
- ** ARRAY HANDLING: FLEXIBLE ARRAYS OF POINTERS
- **
- ** (c) COPYRIGHT MIT 1995.
- ** Please first read the full copyright statement in the file COPYRIGH.
- **
- ** history: Sep 95 HFN Written after looking at Hancock Tower
- */
- /* Library include files */
- #include "tcp.h"
- #include "HTUtils.h"
- #include "HTArray.h" /* Implemented here */
- /* Create a array with a certain allocation unit
- ** --------------
- */
- PUBLIC HTArray * HTArray_new (int grow)
- {
- HTArray * array;
- if ((array = (HTArray *) HT_CALLOC(1, sizeof(HTArray))) == NULL)
- HT_OUTOFMEM("HTArray_new");
- array->growby = grow;
- return array;
- }
- /* Clear a array of all data
- ** --------------------------
- */
- PUBLIC BOOL HTArray_clear (HTArray * array)
- {
- if (array) {
- HT_FREE(array->data);
- array->size = 0;
- array->allocated = 0;
- return YES;
- }
- return NO;
- }
- /* Free an array
- ** -------------
- */
- PUBLIC BOOL HTArray_delete (HTArray * array)
- {
- if (array) {
- HT_FREE(array->data);
- HT_FREE(array);
- return YES;
- }
- return NO;
- }
- /* Add an object
- ** -------------
- */
- PUBLIC BOOL HTArray_addObject (HTArray * array, void * object)
- {
- if (array) {
- if (array->size >= array->allocated-1) {
- if (array->data) {
- if ((array->data = (void * *) HT_REALLOC(array->data, (array->allocated+array->growby) * sizeof(void *))) == NULL)
- HT_OUTOFMEM("HTArray_add");
- memset((array->data+array->allocated), '', array->growby * sizeof(void *));
- } else {
- if ((array->data = (void * *) HT_CALLOC(array->growby, sizeof(void *))) == NULL)
- HT_OUTOFMEM("HTArray_add");
- }
- array->allocated += array->growby;
- }
- *(array->data+array->size++) = object;
- return YES;
- }
- return NO;
- }
- /* Sort an array
- ** -------------
- */
- PUBLIC BOOL HTArray_sort (HTArray * array, HTComparer * comp)
- {
- if (array && comp) {
- qsort(array->data, array->size, sizeof (void *), comp);
- return YES;
- }
- return NO;
- }