Personal tools
You are here: Home Projects C++ Cfront releases Release 3.0.3 source libSC Path ksh t.c
Document Actions

t.c

by Michael L Powell last modified 2007-01-26 03:24

Click here to get the file

Size 1 kB - File type text/plain

File contents

/*ident "@(#)Path:ksh/t.c	3.1" */
#include <Pool.h>
#include <String.h>
#include <assert.h>
#include <iostream.h>
#include <sys/param.h>

static VPool *pool;

static void poolcreate(size_t n, size_t exp)
{
	pool = new VPool(n, exp);
}

static void found(const char *p)
{
	cout << "found: " << p << endl;
}

static char * alloc()
{
	return (char*)pool->alloc();
}

static void shrink(char *p, size_t n)
{
	int i = pool->shrink(p, n);
	assert(i==1);
}

extern "C" path_expand(const char *, 
		void (*found)(const char *), 
		void (*poolcreate)(size_t, size_t), 
		char * (*alloc)(), 
		void (*shrink)(char *, size_t));

main()
{
	String s;
	while (1)
	{
		cout << "Pattern to expand? ";
		cin >> s;
		int i = path_expand(s, found, poolcreate, alloc, shrink);
//		cout << i << " files (mem utilization was " << pool->memory_utilization() << ")\n";
		delete pool;
	}

}
« April 2024 »
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
 

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: