Old 28th July 2005, 23:44   #1
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
Stack plugin

Last few days I'm wrote header on "C" with linear (one direction) and bilinear (two directions) stack functions. I has thought if make NSIS plugin that probably will be useful for somebody.

Functions for working with NSIS stack (linear):
ns_push_front (same as Push)
ns_pop_front (same as Pop)
ns_push_back
ns_stack_read
ns_stack_write
ns_stack_size
ns_stack_free

Functions for working with private stack (bilinear):
dll_push_front
dll_pop_front
dll_push_back
dll_pop_back
dll_stack_read
dll_stack_write
dll_stack_insert
dll_stack_delete
dll_stack_size
dll_stack_free
Attached Files
File Type: zip stack.zip (10.9 KB, 468 views)
Instructor is offline   Reply With Quote
Old 29th July 2005, 04:24   #2
Joel
Debian user
(Forum King)
 
Joel's Avatar
 
Join Date: Jan 2003
Location: Arch land
Posts: 4,917
Cool :up:
I can share with you my NOT crt function of lstrcmp since once I also use it :tinfoil:
PHP Code:
int _stdcall _strcmp(chars1chars2)
{
    for (; *
s1 && *s2; ++s1, ++s2)
    {
        if ( *
s1 != *s2 )
        {
            break;
        }
    }
    return *
s1 - *s2;



* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with MATE.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with MATE.
Joel is offline   Reply With Quote
Old 29th July 2005, 09:56   #3
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
If you talk about lstrcmp, probably the correct variant will be:

PHP Code:
int __stdcall _strcmp(char *s1char *s2)
{
    for (;(*
s1) && (*s2); ++s1, ++s2)
        if (*
s1 < *s2)
            return -
1;
        else if (*
s1 > *s2)
            return 
1;

    if ((!*
s1) && (!*s2))
        return 
0;
    else if (!*
s1)
        return -
1;
    else
        return 
1;

Instructor is offline   Reply With Quote
Old 29th July 2005, 11:51   #4
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
lstrcmp is not part of CRT. You're confusing it with strcmp. lstrcmp is a Windows API, defined in kernel32.dll. There's no need to write a replacement for it.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 10th August 2005, 08:49   #5
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
Changes:

- New: Supports multi-stack (StackFunc.h).
- Fixed: xitoa string missing terminating null character when number is "0" (ConvFunc.h).

Functions for working with NSIS stack (linear):
- ns_stack_free->ns_stack_clear (function now not uses pop_frontL)

Functions for working with private stack (bilinear):
- Changed: stack_insert now can insert element to the top and first places
- dll_stack_free->dll_stack_clear (function now not uses pop_front)
- New: stack_exchange
- New: stack_delete_range
- New: stack_move
- New: stack_move_range
- New: stack_sort
- New: stack_reverse_range
Attached Files
File Type: zip stack.zip (15.3 KB, 517 views)
Instructor is offline   Reply With Quote
Old 1st September 2005, 12:55   #6
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
Changes:

- New: stack::dll_push_sort (Pushs element to the stack and sorts alphabetically in ascending or descending)

- Added example how to sort lines in a text file

- Supports custom structures (StackFunc.h)


"Stack" plugin v1.2
Attached Files
File Type: zip stack.zip (16.3 KB, 504 views)
Instructor is offline   Reply With Quote
Old 2nd March 2006, 19:39   #7
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
1. New:
dll_push_sort_int
dll_sort_all_int
Debug

2. Renamed:
ns_stack_read->ns_read
ns_stack_write->ns_write
ns_stack_size->ns_size
ns_stack_clear->ns_clear
dll_stack_read->dll_read
dll_stack_write->dll_write
dll_stack_insert->dll_insert
dll_stack_exchange->dll_exchange
dll_stack_reverse_range->dll_reverse_range
dll_stack_delete->dll_delete
dll_stack_delete_range->dll_delete_range
dll_stack_move->dll_move
dll_stack_move_range->dll_move_range
dll_stack_sort->dll_sort_all
dll_stack_size->dll_size
dll_stack_clear->dll_clear

Update from previous versions:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- Insert line in script:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;!include "Stack.nsh"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- Replace:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stack::ns_push_front -> ${stack::ns_push_front} ...
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- Replace:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.r0 -> $0, .r1 -> $1 ... .R0 -> $R0, .R1 -> $R1 ...


"Stack" plugin v1.4
Attached Files
File Type: zip stack.zip (32.1 KB, 524 views)
Instructor is offline   Reply With Quote
Old 3rd March 2006, 15:17   #8
Comm@nder21
Major Dude
 
Join Date: Jul 2003
Location: germany, b-w
Posts: 734
Send a message via ICQ to Comm@nder21
nice one.
Comm@nder21 is offline   Reply With Quote
Old 16th May 2006, 08:53   #9
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
Updated: "StackFunc.h" to v1.7
Added: now possible dynamically create private stacks, all private stack functions
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;now require stack handle in first parameter
Removed: dll_push_front, dll_pop_front, dll_push_back, dll_pop_back, because
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dll_insert and dll_delete can be used

"Stack" plugin v1.5
Attached Files
File Type: zip stack.zip (32.1 KB, 491 views)
Instructor is offline   Reply With Quote
Old 17th May 2006, 00:49   #10
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
Updated: "StackFunc.h" to v1.8

"Stack" plugin v1.6
Attached Files
File Type: zip stack.zip (32.2 KB, 505 views)
Instructor is offline   Reply With Quote
Old 27th November 2009, 17:23   #11
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
Updated: "StackFunc.h" to v3.0

"Stack" plugin v1.7
Attached Files
File Type: zip stack.zip (36.3 KB, 170 views)
Instructor is offline   Reply With Quote
Old 4th January 2011, 14:13   #12
Marshall7a
Junior Member
 
Join Date: Oct 2004
Location: UK
Posts: 33
The documentation doesn't mention that you have to clear a private stack before you destroy it, otherwise memory is leaked for the elements on the stack!

I've never been very sure about what is right. I'm not even sure that there is such a thing as right. Or wrong. Just places to stand.
Marshall7a is offline   Reply With Quote
Old 20th June 2013, 10:10   #13
Marshallx7
Junior Member
 
Join Date: Oct 2012
Posts: 36
There appears to be a memory leak in the private stacks. I just created a test script that inserts 10,000 elements, then deletes them.
Memory usage before create: 1,380KB
Memory usage after create: 1,392KB
Memory usage after 10,000 inserts: 12,432KB
Memory usage after 10,000 deletes: 2,712KB
Destroyed but not unloaded: 2,588 KB

I tried the same thing with inserting and deleting 1,000,000 elements (this took a long time to run) and the memory usage at the end was over 190 MB !
Marshallx7 is offline   Reply With Quote
Old 16th September 2013, 16:59   #14
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
Added: full unicode support on NSIS Unicode.
Fixed: ${stack::dll_destroy} didn't erase the stack before destroying.

Stack plugin v1.8
Instructor is offline   Reply With Quote
Old 17th September 2013, 19:02   #15
aerDNA
Senior Member
 
aerDNA's Avatar
 
Join Date: Feb 2007
Location: Rijeka, Croatia
Posts: 225
I've found Stack precious in several scripts, thank you. Nice to see it up to date.

PostEnd:
aerDNA is offline   Reply With Quote
Old 18th September 2013, 19:39   #16
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
Added: ${stack::ns_pop_back} - removes the element from the end of the NSIS stack and puts it in the variable.
Added: ${stack::ns_insert} - inserts new element at specified index of the NSIS stack.
Added: ${stack::ns_delete} - finds the NSIS element by index, puts it in the variable and removes it.

Stack plugin v2.0
Instructor is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump