Do you remember a previous discussion on this newsgroup as at http://groups.google.com/group/comp....738c4f91113b4e
It concerned code to manage a buffer, expanding it as needed semi
automatically. I've incorporated suggestions people made and published
the code at http://codewiki.wikispaces.com/xbuf.c
(For the impatient check the last two links in the table of contents
for the code. The rest is documentation.)
The code is intended to be fast. It's uses include reading an
arbitrary-length line from an input stream - a safe gets() replacement
if you like - but it is more flexible than line reading functions and
is intended to be useful in more cases than just line reading.
--NB. Code and documentation are on a wiki. If you see things that
should be changed feel free to change them.
Apart from the code itself what do you think of the concept of
publishing it on a wiki...?
James 3 2700
On Nov 15, 8:12*pm, James Harris <james.harri... @googlemail.com >
wrote:
Do you remember a previous discussion on this newsgroup as at
*http://groups.google.com/group/comp....hread/cb502ce8....
It concerned code to manage a buffer, expanding it as needed semi
automatically. I've incorporated suggestions people made and published
the code at
*http://codewiki.wikispaces.com/xbuf.c
(For the impatient check the last two links in the table of contents
for the code. The rest is documentation.)
The code is intended to be fast. It's uses include reading an
arbitrary-length line from an input stream - a safe gets() replacement
if you like - but it is more flexible than line reading functions and
is intended to be useful in more cases than just line reading.
--NB. Code and documentation are on a wiki. If you see things that
should be changed feel free to change them.
Apart from the code itself what do you think of the concept of
publishing it on a wiki...?
James
Nice presentation. You'll probably get less heap fragmentation for
programs that use lots of buffers if all of them are at set standard
sizes. So your new_size computation would become something like
new_size = current_size;
while (new_size < requested_size)
new_size = new_size * FACTOR;
NB. Your choice of default 3 / 2 for FACTOR is interesting. I've
been using this for many years because the standard 2 seemed
extravagant.
On 18 Nov, 17:53, Gene <gene.ress...@g mail.comwrote:
....
Is there a better way to increase the buffer size? Especially as the
address space fills up should the increase factor be reduced, and how?
Anyone been down this road?
Garbage collectors deal with this when they need to increase the pool
size when not much VM is left. There isn't a single best policy
because behavior depends heavily on the OS.
Agreed. The more I think about this the less I think there is any kind
of one-size-fits-all solution. One advantage of distributing as source
code is that people can vary the code to suit their situation. I've
kept the original code as it was but have documented some alternatives
as comments within the code. http://codewiki.wikispaces.com/xbuf.c
The commented alternatives are purely illustrative and are untested. I
hope I've got the C syntax etc correct. Either way they should be
enough to illustrate the options to anyone using the code. If you,
dear reader, see an error feel free to fix it or let me know what I've
got wrong and I'll fix it.
James
James Harris wrote:
Gene <gene.ress...@g mail.comwrote:
.... snip ...
>
>Garbage collectors deal with this when they need to increase the pool size when not much VM is left. There isn't a single best policy because behavior depends heavily on the OS.
Agreed. The more I think about this the less I think there is any
kind of one-size-fits-all solution. One advantage of distributing
as source code is that people can vary the code to suit their
situation. I've kept the original code as it was but have
documented some alternatives as comments within the code.
In general you should adjust the mechanism to fit the expected
use. As an example, my ggets routine expands the buffer in
constant increments (of 128), because its primary use is expected
to be interactive input, and those strings are not normally
unlimited. However my hashlib expands its table by a factor of two
each time, resulting in constant average overhead, and basically
eliminating consideration of table size. In each case there are
possible penalties.
--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home .att.net>
Try the download section. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jeffrey Kilpatrick |
last post by:
I have a SQL 6.5 database that we parse some data into everyday using
an access program. All this was devises and setup by a programmer that
I can't get in contact with anymore and it has actually run for about
five years without a hickup! But just a few days ago our parsing
program just stops dead before completing and I did get this error
message.
"exportaLLdataToSQLifnoerror(): number 3146 Description- odbd- call
failed. Can't...
|
by: David |
last post by:
It's sad to say, but when using the AOL web site, like to send an
email, they have a nifty capability such that when a window is
resized, the textarea where the message is input expands not only
horizontally, but also vertically, to fill the space.
I took a look at their javascripts, but they are quite complex and
convoluted since they make use of many of their own functions designed
to work with their web site.
Does anybody have a...
|
by: erikd |
last post by:
I'm using an expanding tree menu based on the design from Dieter
Bungers GMD (www.gmd.de) and infovation (www.infovation.de) named
displayToc.js. The problem is that the script isn't working properly
in Firefox, although it's working without problems in IE 5.5 & 6.0 In
Firefox any file which isn't in the same directory isn't found, so the
images are missing and the links don't launch. It may be something
simple, but I don't have the...
|
by: Bhiksha Raj |
last post by:
Hi,
I created an expanding menu on one of the frames in my
webpage using code I got from
http://www.dynamicdrive.com/dynamicindex1/navigate1.htm
I have embedded the code (with minor modification to point
to my links) into a frame on my webpage.
The problem is that when I open the page on netscape 7,
|
by: alkhatib |
last post by:
Hi Experts,
I'm working on Win2k platform, where a process is wrinting to a log
(plain text in tabular form) .
My goal is to view this grawing log on access database, I linked a
| |
by: Mihajlo Cvetanovic |
last post by:
Hi all,
I'm writing a winsock app and I want to recv bytes in C++ way. How can
I expand (grow) strstreambuf once it's created? Is there a better
class instead of strstreambuf?
Now I have a CBuffer class with a char* dynamic buffer, the size of
the buffer and the length of useful data in the buffer. It has all I
need, but why "reinventing the wheel" if it's already available...
|
by: Jack |
last post by:
Hello,
I would like some advice on how to disable the behavior of treeviews to
expand and collapse when double clicked upon, but still allow the user to use
the plus and minus on each node.
Thanks in advance!
Jack
|
by: Chrisjc |
last post by:
I am in need of an expanding and collapsing code… The goal is
To be able to click a PICTURE IMAGE and expand to show information
Reason for this is I have 3 TABLES of information of about
400x200… that I want to be able to expand to how much information I put in them…. Just need a code that will cut it off and then OPEN it…
So
|
by: James Harris |
last post by:
Initial issue: read in an arbitrary-length piece of text.
Perceived issue: handle variable-length data
The code below is a suggestion for implementing a variable length
buffer that could be used to read text or handle arrays of arbitrary
length. I don't have the expertise in C of many folks here so I feel
like I'm offering a small furry animal for sacrifice to a big armour
plated one... but will offer it anyway. Please do suggest...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |