home *** CD-ROM | disk | FTP | other *** search
- head 1.3;
- access;
- symbols;
- locks; strict;
- comment @ * @;
-
-
- 1.3
- date 92.08.18.04.46.58; author dglattin; state Exp;
- branches;
- next 1.2;
-
- 1.2
- date 92.04.13.11.43.08; author dennisg; state Exp;
- branches;
- next 1.1;
-
- 1.1
- date 92.02.25.11.12.45; author dennisg; state Exp;
- branches;
- next ;
-
-
- desc
- @Really just a temporary thing.
- Provides a OO technique to access an array.
- Its use was to provide a solid array interface rather than
- blind indexing. Worked well I might add.
- @
-
-
- 1.3
- log
- @Saving a working version before release.
- @
- text
- @/* -*-c-*- */
-
- /* Copyright (C) 1989, 1992 Free Software Foundation, Inc.
-
- This file is part of GNU CC.
-
- GNU CC 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 2, or (at your option)
- any later version.
-
- GNU CC 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 GNU CC; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
- /* As a special exception, if you link this library with files
- compiled with GCC to produce an executable, this does not cause
- the resulting executable to be covered by the GNU General Public License.
- This exception does not however invalidate any other reasons why
- the executable file might be covered by the GNU General Public License. */
-
- /*
- * $Header: /usr/user/dennis_glatting/ObjC/c-runtime/lib/RCS/objc-core.c,v 1.14
- * 1992/01/03 02:55:03 dennisg Exp dennisg $ $Author: dennisg $ $Date:
- * 1992/01/03 02:55:03 $ $Log: record-inline.h,v $
- * Revision 1.2 1992/04/13 11:43:08 dennisg
- * Check in after array version of run-time works.
- * Expect more changes as hash version and other changes are made.
- *
- * Revision 1.1 1992/02/25 11:12:45 dennisg
- * Initial revision
- *
- */
-
-
- #ifndef _record_inline_INCLUDE_GNU
- #define _record_inline_INCLUDE_GNU
-
- #include <assert.h>
- #include <stdlib.h>
- #include <sys/types.h>
-
- /* Structure to hold records. */
- typedef struct _Record {
- u_int capacity,
- numEntries;
- void* (*records)[];
- } Record, *Record_t;
-
-
- /* Allocate, initialize and return a new record structure. */
- static inline Record_t
- record_new (void) {
-
- Record_t newRecord;
-
-
- newRecord = calloc (1, sizeof (Record));
- assert(newRecord);
- newRecord->capacity = 8;
- newRecord->records = calloc (newRecord->capacity, sizeof (void*));
- assert(newRecord->records);
-
- return newRecord;
- }
-
-
- /* Delete the record. */
- static inline void
- record_delete (Record_t record) {
-
- free (record->records);
- free (record);
- }
-
-
- /* Return the number of entries in the reord. */
- static inline u_int
- record_entries (Record_t record) {
-
- return record->numEntries;
- }
-
-
- /* return the capacity of the record. */
- static inline u_int
- record_capacity (Record_t record) {
-
-
- return record->capacity;
- }
-
-
- /* Store an entry at the specified record location. */
- static inline void
- record_store_at (u_int i, void* value, Record_t record) {
-
-
- assert(i);
- assert(i <= record_entries (record));
-
- (*record->records)[ i ] = value;
- }
-
-
- /* Make a record entry. Expand the record's size if full. */
- static inline void
- record_store (void* value, Record_t record) {
-
-
- ++record->numEntries;
- if(record_entries (record) == record_capacity (record)) {
- record->capacity *= 2;
- record->records =
- realloc (record->records, (record_capacity (record) * sizeof (void*)));
- }
- record_store_at (record_entries (record), value, record);
- }
-
-
- /* get a value from the record. */
- static inline void*
- record_get (u_int i, Record_t record) {
-
-
- assert( i );
- assert( i <= record_entries (record));
- return (*record->records)[ i ];
- }
-
- #endif
-
- @
-
-
- 1.2
- log
- @Check in after array version of run-time works.
- Expect more changes as hash version and other changes are made.
- @
- text
- @d1 27
- a27 22
- /*
- * -*-c-*- The routines in this file are used to simplify record keeping in
- * the run-time.
- *
- * Generally each function does not include a documentation header before its
- * implementation. Such headers are found in interface header files.
- *
- * Copyright (C) 1991 Threaded Technologies Inc.
- *
- * 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 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 receive 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.
- *
- d31 4
- d44 3
- a46 3
- #include <assert.h>
- #include <stdlib.h>
- #include <sys/types.h>
- d48 7
- a54 7
- /* Structure to hold records. */
- typedef struct _Record {
- u_int capacity,
- numEntries;
- void* (*records)[];
- } Record, *Record_t;
-
- d60 10
- a69 10
- Record_t newRecord;
-
-
- newRecord = calloc (1, sizeof (Record));
- assert(newRecord);
- newRecord->capacity = 8;
- newRecord->records = calloc (newRecord->capacity, sizeof (void*));
- assert(newRecord->records);
-
- return newRecord;
- d77 2
- a78 2
- free (record->records);
- free (record);
- d86 1
- a86 1
- return record->numEntries;
- d95 1
- a95 1
- return record->capacity;
- d104 2
- a105 2
- assert(i);
- assert(i <= record_entries (record));
- d107 1
- a107 1
- (*record->records)[ i ] = value;
- d116 7
- a122 7
- ++record->numEntries;
- if(record_entries (record) == record_capacity (record)) {
- record->capacity *= 2;
- record->records =
- realloc (record->records, (record_capacity (record) * sizeof (void*)));
- }
- record_store_at (record_entries (record), value, record);
- d131 3
- a133 3
- assert( i );
- assert( i <= record_entries (record));
- return (*record->records)[ i ];
- @
-
-
- 1.1
- log
- @Initial revision
- @
- text
- @d25 4
- a28 1
- * 1992/01/03 02:55:03 $ $Log: objc-core.c,v $
- d56 1
- a56 1
- newRecord->capacity = 128;
- @
-