Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Patch for curses module
- X-seq: zsh-workers 36528
- From: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: Patch for curses module
- Date: Sun, 13 Sep 2015 13:58:11 +0200
- Cc: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=7yrbIgRxbLwC4qXPNWJ/f3kYhc8SPMiz2OeSADUwo9A=; b=0n0+Wuk4CoVcdZvboDczt0dyaRoOqCtCkD3Y28E6gil7qLWt/WoHAilQW0qxDBrM4N +Q3rLu159mqTfdVtf/cLGd9jpGoUdjp2lGc71nqigxoaFuzizuD8s/f2+2cIHokDEUVU 0xRgtKQ9DbW0UUJaqCgSUzaZZPXXXDt8SSOwO9UpC8Mm3O/d827G/j6PZmAsRdzLNp4P G6jxbLRNQOHEOrFbnPK7NkEXFPZNQ+URzG7Va8j91NUyA5eR/YWTVUj+MIFrRKFKZiqm 87/gPLxbC3Ybnd52sCPltHcYZ68GsBPiCZH0n7IJPIV2VAmizcSlD5EGW5U8Bbz3XGgq 7W+w==
- In-reply-to: <150912113349.ZM12036@torch.brasslantern.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAKc7PVAKmGZrDfbA-A8bpZ+6kM+ibBr6pkFbG_5=jumLJcREFw@mail.gmail.com> <CAKc7PVAXVXOzwr3MO_oyBEgaWuSBHXz+CJH62UW3p73w=v+ipQ@mail.gmail.com> <150912090835.ZM11765@torch.brasslantern.com> <CAKc7PVDsEN4NOed3uLGiW=NXaF48EQtEURqZ3+ZN=hsH1bo17A@mail.gmail.com> <CAKc7PVAxkEVpcKeA+wJS6ixZkdK0Xnm62fCP-JTyFYaW5ZFTsw@mail.gmail.com> <150912113349.ZM12036@torch.brasslantern.com>
You are apparently right, it wasn't the next color pair that fixed
white/black, but new creation of white/black that at one time
succeeded.
I'm now trying to provide a clean memory block for the zalloc call by
doing preceding 16 byte allocations and frees. The 16 bytes comes from
size of colorpairnode struct. It's 16 on x86 and 32 on 64 bit machine.
I am hoping that zalloc will reuse the memory blocks. Doing simple
test in C showed that it's reasonable to expect this:
#include <stdlib.h>
#include <stdio.h>
int main() {
char * a = (char*) malloc(16);
free(a);
char * b = (char*) malloc(16);
free(b);
printf(" %p vs %p ", a, b );
return 0;
}
The test worked on FreeBSD, OSX and Linux. I also added traces to
zalloc() to ensure that it will call malloc(16), and obtained that
this will be done for 15 chars long string assignment (but not for 15
zeros '$\0...', what's interesting).
So I do the following before calling zcurses:
_provide_clean_memory_to_old_zsh() {
local i=100
while (( i-- )); do
local a b
a=" "
b=" "
unset a b
done
}
The disabled flag is defined as follows:
#define DISABLED (1<<0)
Hash node which is part of colorpairnode as:
struct hashnode {
HashNode next; /* next in hash chain */
char *nam; /* hash key */
int flags; /* various flags */
};
Therefore filling a 16/32 byte area with zeros or e.g. spaces and then
freeing it should provide proper memory for zcurses. But this doesn't
happen. Does unset free memory? What can be done to allocate and free
16/32 bytes block?
Best regards,
Sebastian Gniazdowski
On 12 September 2015 at 20:33, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Sep 12, 7:40pm, Sebastian Gniazdowski wrote:
> }
> } I wonder how can creating subsequent color pair make previous pairs
> } non-disabled. It happens in random manner, sometimes it helps and
> } sometimes not. In first reply I attached a log where red/black fixed
> } white/black
>
> Looking at your trace, I see white/black being created twice, the
> second time after it was cache-missed for DISABLED but also before
> the red/black is created. The second time white/black is created
> is when I believe it "fixes" the DISABLED bit.
>
> Am I misreading the trace, or misunderstanding the sequence of events
> that created the trace?
Messages sorted by:
Reverse Date,
Date,
Thread,
Author