News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

resize a buffer at runtime

Started by zigzag, February 10, 2012, 08:28:52 PM

Previous topic - Next topic

zigzag

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?

Vortex

A quick solution is to copy the string to a larger buffer to accept more characters.

zigzag


SteveAsm

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.

dedndave

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?

hutch--

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.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Vortex

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.

dedndave

i have seen that acronym before
with all the acronyms in microsoft-world, i can't remember all of them

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"

hutch--

 :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.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

jj2007

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

oex

aSM programers theze days.... There;s no atencion to detale.... ::)
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv