The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: zigzag on February 10, 2012, 08:28:52 PM

Title: resize a buffer at runtime
Post by: zigzag on February 10, 2012, 08:28:52 PM
hi..

i have a buffer that is filled at runtime with a string, i want to append a character to the end of the randomly-sized string.. the problem is that once the buffer has been filled it now has a fixed length and i cannot append any character to it. so how could i do this?
Title: Re: resize a buffer at runtime
Post by: Vortex on February 10, 2012, 08:32:25 PM
A quick solution is to copy the string to a larger buffer to accept more characters.
Title: Re: resize a buffer at runtime
Post by: zigzag on February 10, 2012, 09:34:42 PM
vortex ... do you knpw spth?
Title: Re: resize a buffer at runtime
Post by: SteveAsm on February 10, 2012, 10:40:29 PM
Quote from: zigzag on February 10, 2012, 08:28:52 PM
i want to append a character to the end of the randomly-sized string..

What do you mean by "randomly-sized" ?

Is this a fixed length array or a pointer that points to dynamically malloc'd array space ?

Quote
the problem is that once the buffer has been filled it now has a fixed length and i cannot append any character to it.

This sounds like a fixed length array.
I would start with an array pointer and malloc the needed space.
Then, as needed realloc more space as your string length increases.
Title: Re: resize a buffer at runtime
Post by: dedndave on February 11, 2012, 04:42:09 AM
different requirements call for different measures   :P

if you are going to use the buffer over and over and the strings are small, just make a buffer in .DATA?
Title: Re: resize a buffer at runtime
Post by: hutch-- on February 11, 2012, 06:14:10 AM
Steve's comment is where the action is, effectively you use dynamic memory allocation for tasks of that type and Windows has a variety of memory allocation techniques to do that. HeapAlloc(), GlobalAlloc(), VirtualAlloc(), OLE string memory or some pof the memory allocation strategies available to COM programming.

Basically you ALLOCATE an initial size, REALLOC when you need to change the size and FREE when you are finished with it, each Windows technique can do all of these operations.
Title: Re: resize a buffer at runtime
Post by: Vortex on February 11, 2012, 08:45:58 AM
Quote from: zigzag on February 10, 2012, 09:34:42 PM
vortex ... do you knpw spth?

What does mean spth?

If you don't provide enough information, we cannot help you. I dont't think that any member in this forum has the telepathic capacity to read your brain.
Title: Re: resize a buffer at runtime
Post by: dedndave on February 11, 2012, 01:16:41 PM
i have seen that acronym before
with all the acronyms in microsoft-world, i can't remember all of them

acronyms.thefreedictionary.com/SPTH (http://acronyms.thefreedictionary.com/SPTH)
SPTH   Speech Pathology (college course)
SPTH   Second Part To Hell (computer virus)
SPTH   Site Potential Tree Height
SPTH   Speech Theatre (college course)
SPTH   Spermatheca
SPTH   Sequential Prefetch Threshold
SPTH   Shortest Path Heuristic
SPTH   Scandpower Petroleum Technology Holding
SPTH   Speckle Pattern Time History

pick one that looks like it applies - lol
i am guessing "Shortest Path Heuristic"
Title: Re: resize a buffer at runtime
Post by: hutch-- on February 11, 2012, 01:41:39 PM
 :bg

I think he was trying to use "internet" speech for "something". Now while you may ROFL or at least LOL, its evident that you guys did not spend years on IRC listening to all of this chyte from PPL who were 2 PHUKING lazy to type out the words that were supposed to be saying.
Title: Re: resize a buffer at runtime
Post by: jj2007 on February 11, 2012, 04:31:36 PM
Quote from: zigzag on February 10, 2012, 09:34:42 PM
vortex ... do you knpw spth?

Guys, you are on the wrong track. He missed the o twice, so the question is "vortex ... do you know something?", to which I would answer straightaway "NO, I am innocent!" :bdg
Title: Re: resize a buffer at runtime
Post by: oex on February 11, 2012, 06:27:53 PM
aSM programers theze days.... There;s no atencion to detale.... ::)