stralloc.c (v4) - people remember this, right?

Maps, modifications, add-ons, projects, and other releases for Zandronum. Also includes announcers.
Post Reply
Ijon Tichy
Frequent Poster Miles card holder
Posts: 901
Joined: Mon Jun 04, 2012 5:07 am

stralloc.c (v4) - people remember this, right?

#1

Post by Ijon Tichy » Mon Jun 04, 2012 9:21 am

It's basically malloc, realloc, and free for strings. Yes, it works just fine with StrParam strings (that's what this was made for, after all).

Puke script 293 for a self-test.

Source code and object file included in the PK3, along with the help and license files.
Spoiler: LICENSE (Open)
Copyright (c) 2012, Ijon Tichy
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.
Spoiler: HELP (Open)
This library is meant to act as a mechanism to store and recall strings in a
simple, universal way, mostly because StrParam strings only last for one tic.
You have a few functions to assist this:

- addString(int string): Adds a string to the strings[] array, making sure it
doesn't overlap with any strings currently in it. Returns the index of the
string.

- addCleanString(int string): Like addString, but removes non-printing
characters.

- getString(int index): Returns the string in strings[] at the index provided.

- stringLength(int index): Returns the length of the string at the index
provided.

- freeString(int index): Frees the string in strings[] at the index provided.

- reallocString(int index, int string): Basically, freeString(index) and
addString(string).

- reallocCleanString(int index, int string): reallocString, but removes
non-printing characters.

- dumpStrings(int stop): Dumps all the strings whose meta-index falls between 0
and $stop. A $stop value of 0 means "go until you hit a null value" - unless
something breaks, this generally means "all of them and no more".

The strings saved last forever - through map changes, through intermissions -
basically until the entire game is reset (through a "map" command). This makes
this library ideal for saving strings for later use.

There are a few functions not meant for external use. Those are addIndex,
getIndex, and freeIndex. Don't use them directly. You'll fuck things up. Trust
me on this one.

Here, have a link: http://ijontichy.lostsig.com/wads/stralloc4.pk3
Mirror 1: http://speedy.sh/QhrP5/stralloc4.pk3
Mirror 2: http://devilhunter.rfc1337.net/wads/Ran ... alloc4.zip
Mirror 3: http://meta.filesmelt.com/dl/stralloc4.zip

And by the way...
YEAH BITCHES, YOU CAN INPUT STRINGS TO ZANDRONUM. FROM IN-GAME.
Spoiler: manliness (Open)
Image
Last edited by Ijon Tichy on Tue Jul 31, 2012 7:32 am, edited 1 time in total.

Watermelon
Zandrone
Posts: 1244
Joined: Thu Jun 28, 2012 9:07 pm
Location: Rwanda

RE: stralloc.c (v4) - people remember this, right?

#2

Post by Watermelon » Sat Jul 28, 2012 9:34 pm

Is this working for anyone? I can't get it from the DL link, just seeing what is done here makes me fill my pants.

User avatar
DevilHunter
Zandronum Tester
Posts: 635
Joined: Sun Jun 17, 2012 12:58 am
Location: Alaska, USA
Contact:

RE: stralloc.c (v4) - people remember this, right?

#3

Post by DevilHunter » Sat Jul 28, 2012 11:19 pm

I got though one time, then it stopped downloading midway. Now I just get waiting for filesmelt.com

Synert
Forum Regular
Posts: 228
Joined: Mon Jun 04, 2012 12:54 pm
Contact:

RE: stralloc.c (v4) - people remember this, right?

#4

Post by Synert » Sat Jul 28, 2012 11:29 pm

I downloaded it ages ago, I'll go upload it in a second

*edit* aaaand here we go

DevilHunter, you may as well mirror it
Last edited by Synert on Sat Jul 28, 2012 11:30 pm, edited 1 time in total.

User avatar
DevilHunter
Zandronum Tester
Posts: 635
Joined: Sun Jun 17, 2012 12:58 am
Location: Alaska, USA
Contact:

RE: stralloc.c (v4) - people remember this, right?

#5

Post by DevilHunter » Sun Jul 29, 2012 12:18 am

Sorry it took so long. My net is really unstable atm but here it is.

stralloc4.zip

Enjoy :p

Ijon Tichy
Frequent Poster Miles card holder
Posts: 901
Joined: Mon Jun 04, 2012 5:07 am

RE: stralloc.c (v4) - people remember this, right?

#6

Post by Ijon Tichy » Tue Jul 31, 2012 7:27 am

yo

another link

edit: it's also the main link now bitcheeeessss
Last edited by Ijon Tichy on Tue Jul 31, 2012 7:30 am, edited 1 time in total.

Post Reply