english
version "1.0"
identify "wxyz"

#: Copyright (c) 1995-1996, 2002 by Wayne C. Gramlich.
#, All rights reserved.
#,
#, Permission to use, copy, modify, distribute, and sell this software
#, for any purpose is hereby granted without fee provided that the above
#, copyright notice and this permission are retained.  The author makes
#, no representations about the suitability of this software for any purpose.
#, It is provided "as is" without express or implied warranty.

module resources

#: This module implements the resource allocation.

define resources			#: Delta memory management object
    record
	chunk manage[chunk]		#: Free {chunk}'s
	chunk_range manage[chunk_range] #: Free {chunk_range}'s
	chunk_ranges manage[chunk_ranges] #: Free {chunk_ranges}'s
	chunks manage[chunks]		#: Free {chunks}'s
	data_in_stream manage[data_in_stream] #: Free {data_in_stream}'s
	data_out_stream manage[data_out_stream] #: Free {data_out_stream}'s
	delta manage[delta]		#: Free {delta}'s
	global global			#: Global information
	history manage[history]		#: Free {history}'s
	project manage[project]		#: Free {project}'s
	project_directory manage[project_directory]
	project_directorys manage[project_directorys]
	project_file manage[project_file] #: Free {project_file}'s
	project_files manage[project_files] #: Free {project_files}'s
	project_name manage[project_name] #: Free {project_name}'s
	share_table manage[set[chunk]]	#: Free share table list
	slice manage[slice]		#: Free {slice}'s
	string manage[string]		# Free (writable) {string}'s
	strings manage[vector[string]]	# Free strings
	version manage[version]		#: Free {version}'s
    generate allocate, erase, identical, print



#: {resources} procedures for managing memory:

procedure create@resources
    takes
	debug logical
	global global
    returns resources

    #: This procedure will create and return a new {resources} object allocated
    #, from {global}.  If {debug} is {true}, an dellocations are checked
    #, very carefully for duplicate dallocations.



procedure leaks_check@resources
    takes
	resources resources
	errors errors
    returns logical

    #: This procedure will verify that all of the object being managed
    #, {resources} have been returned.  If any objects have not been returned
    #, an error message is output to {error_stream} and {true} is returned.


procedure chunk_allocate@resources
    takes
	resources resources
    returns chunk

    #: This procedure will allocate a new {chunk} object from {resources}.


procedure chunk_deallocate@resources
    takes
	resources resources
	chunk chunk
    returns_nothing

    #: This routine will return {chunk} to {resources} for subsequent
    #, reallocation.


procedure chunk_range_allocate@resources
    takes
	resources resources
    returns chunk_range

    #: This procedure will allocate a new {chunk_range} object from
    #, {resources}.


procedure chunk_range_deallocate@resources
    takes
	resources resources
	chunk_range chunk_range
    returns_nothing

    #: This routine will return {chunk_range} to {resources} for subsequent
    #, reallocation.


procedure chunk_ranges_allocate@resources
    takes
	resources resources
    returns chunk_ranges

    #: This procedure will allocate a new {chunk_ranges} object from
    #, {resources}.


procedure chunk_ranges_deallocate@resources
    takes
	resources resources
	chunk_ranges chunk_ranges
    returns_nothing

    #: This routine will return {chunk_ranges} to {resources} for subsequent
    #, reallocation.


procedure chunks_allocate@resources
    takes
	resources resources
    returns chunks

    #: This procedure will allocate a new {chunks} object from {resources}.


procedure chunks_deallocate@resources
    takes
	resources resources
	chunks chunks
    returns_nothing

    #: This routine will return {chunks} to {resources} for subsequent
    #, reallocation.


procedure data_in_stream_allocate@resources
    takes
	resources resources
    returns data_in_stream

    #: This procedure will allocate a new {data_in_stream} object from
    #, {resources}.


procedure data_in_stream_deallocate@resources
    takes
	resources resources
	data_in_stream data_in_stream
    returns_nothing

    #: This routine will return {data_in_stream} to {resources} for subsequent
    #, reallocation.


procedure data_out_stream_allocate@resources
    takes
	resources resources
    returns data_out_stream

    #: This procedure will allocate a new {data_out_stream} object from
    #, {resources}.


procedure data_out_stream_deallocate@resources
    takes
	resources resources
	data_out_stream data_out_stream
    returns_nothing

    #: This routine will return {data_out_stream} to {resources} for
    #, subsequent reallocation.


procedure delta_allocate@resources
    takes
	resources resources
    returns delta

    #: This procedure will allocate a new {delta} object from {resources}.


procedure delta_deallocate@resources
    takes
	resources resources
	delta delta
    returns_nothing

    #: This routine will return {delta} to {resources} for subsequent
    #, reallocation.


procedure history_allocate@resources
    takes
	resources resources
    returns history

    #: This procedure will allocate a new {history} object from {resources}.


procedure history_deallocate@resources
    takes
	resources resources
	history history
    returns_nothing

    #: This routine will return {history} to {resources} for subsequent
    #, reallocation.


procedure project_allocate@resources
    takes
	resources resources
    returns project

    #: This procedure will allocate a new {project} object from {resources}.


procedure project_deallocate@resources
    takes
	resources resources
	project project
    returns_nothing

    #: This routine will return {project} to {resources} for subsequent
    #, reallocation.


procedure project_directory_allocate@resources
    takes
	resources resources
    returns project_directory

    #: This procedure will allocate a new {project_driectory} object
    #, from {resources} and return it.


procedure project_directory_deallocate@resources
    takes
	resources resources
	project_directory project_directory
    returns_nothing

    #: This routine will return {project_directory} to {resources} for
    #, subsequent reallocation.


procedure project_directorys_allocate@resources
    takes
	resources resources
    returns project_directorys

    #: This procedure will allocate a new {vector}[{project_directory}] object
    #, from {resources} and return it.


procedure project_directorys_deallocate@resources
    takes
	resources resources
	project_directorys project_directorys
    returns_nothing

    #: This routine will return {project_directorys} to {resources} for
    #, subsequent reallocation.


procedure project_file_allocate@resources
    takes
	resources resources
    returns project_file

    #: This procedure will allocate a new {project_driectory} object
    #, from {resources} and return it.


procedure project_file_deallocate@resources
    takes
	resources resources
	project_file project_file
    returns_nothing

    #: This routine will return {project_file} to {resources} for
    #, subsequent reallocation.


procedure project_files_allocate@resources
    takes
	resources resources
    returns project_files

    #: This procedure will allocate a new {project_directorys} object
    #, from {resources} and return it.


procedure project_files_deallocate@resources
    takes
	resources resources
	project_files project_files
    returns_nothing

    #: This routine will return {project_files} to {resources} for
    #, subsequent reallocation.


procedure project_name_allocate@resources
    takes
	resources resources
    returns project_name

    #: This procedure will allocate a new {project_name} object from
    #, {resources} and return it.


procedure project_name_deallocate@resources
    takes
	resources resources
	project_name project_name
    returns_nothing

    #: This routine will return {project_name} to {resources} for subsequent
    #, reallocation.


procedure share_table_allocate@resources
    takes
	resources resources
    returns set[chunk]

    #: This procedure will allocate a new share table from {resources}


procedure share_table_deallocate@resources
    takes
	resources resources
	share_table set[chunk]
    returns_nothing


procedure slice_allocate@resources
    takes
	resources resources
    returns slice

    #: This procedure will allocate a new {slice} object from {resources}.


procedure slice_deallocate@resources
    takes
	resources resources
	slice slice
    returns_nothing

    #: This routine will return {slice} to {resources} for subsequent
    #, reallocation.


procedure string_allocate@resources
    takes
	resources resources
    returns string

    #: This procedure will allocate a new {string} object from {resources}.


procedure string_deallocate@resources
    takes
	resources resources
	string string
    returns_nothing

    #: This routine will return {string} to {resources} for subsequent
    #, reallocation.


procedure strings_allocate@resources
    takes
	resources resources
    returns vector[string]

    #: This procedure will allocate a new string list object from {resources}.


procedure strings_deallocate@resources
    takes
	resources resources
	strings vector[string]
    returns_nothing

    #: This routine will return {strings} to {resources} for subsequent
    #, reallocation.


procedure version_allocate@resources
    takes
	resources resources
    returns version

    #: This procedure will allocate a new {version} object from {resources}.


procedure version_deallocate@resources
    takes
	resources resources
	version version
    returns_nothing

    #: This routine will return {version} to {resources} for subsequent
    #, reallocation.