On Mon, 2011-01-17 at 13:33 +0100, Benoît Minisini wrote:
> > sorry my wrong expression.
> >
>
> No problem.
>
> Another point: at the moment, Alloc() and Free() are not the equivalent of
> malloc() and free() in C. So you cannot use Free() to free a memory
> allocation
> returned as a pointe
> sorry my wrong expression.
>
No problem.
Another point: at the moment, Alloc() and Free() are not the equivalent of
malloc() and free() in C. So you cannot use Free() to free a memory allocation
returned as a pointer by a C function. You must use the free() function
located in the C library
sorry my wrong expression.
On Mon, 2011-01-17 at 12:27 +0100, Benoît Minisini wrote:
> >
> > i dont think that C++ programmers will come to Gambas to use external
> > functions, the opposite i think will be.
> >
>
> We are talking about C. Calling C++ functions from Gambas is almost
> impossib
>
> i dont think that C++ programmers will come to Gambas to use external
> functions, the opposite i think will be.
>
We are talking about C. Calling C++ functions from Gambas is almost
impossible.
--
Benoît Minisini
--
On Mon, 2011-01-17 at 22:00 +1100, Ian Haywood wrote:
> On Mon, Jan 17, 2011 at 9:50 PM, Demosthenes Koptsis
> wrote:
> >
> > Benoit sorry if you feel that i discuss C++ cases in a Gambas list but i
> > try to describe some cases of pointers and the usage of them in Gambas.
> IMHO the issue is C p
On Mon, Jan 17, 2011 at 9:50 PM, Demosthenes Koptsis
wrote:
>
> Benoit sorry if you feel that i discuss C++ cases in a Gambas list but i
> try to describe some cases of pointers and the usage of them in Gambas.
IMHO the issue is C pointers aren't an easy topic and good conceptual
understanding
is
Benoit sorry if you feel that i discuss C++ cases in a Gambas list but i
try to describe some cases of pointers and the usage of them in Gambas.
For me and as i think for any Gambas developer the subject of pointers
and reading man 3 is a new thing.
Same questions may be come also in the future
On Mon, 2011-01-17 at 11:08 +0100, Benoît Minisini wrote:
> > Here is a last case about pointers i found.
> >
> > CASE 1
> > ---
> > When a C++ function does not malloc any memory it may return a pointer.
> > In this case we can do
> >
> > DIM pPointer as Pointer
> > pPointer = Alloc(4096)' a
> Here is a last case about pointers i found.
>
> CASE 1
> ---
> When a C++ function does not malloc any memory it may return a pointer.
> In this case we can do
>
> DIM pPointer as Pointer
> pPointer = Alloc(4096)' alloc 4096 bytes
>
> pPointer = getwd(pBuf)
>
> 'use pPointer with Str@() o
Here is a last case about pointers i found.
CASE 1
---
When a C++ function does not malloc any memory it may return a pointer.
In this case we can do
DIM pPointer as Pointer
pPointer = Alloc(4096)' alloc 4096 bytes
pPointer = getwd(pBuf)
'use pPointer with Str@() or other xxx@()
Free(pPoin
Hah! OK, I didn't guess there would be so detailed information!
So, I think this is OK then!
Jussi
2011/1/11 Benoît Minisini
> > > if i use
> > > s=Str@(pPointer)
> > >
> > > this means
> > > address1=adress2 ?
> >
> > Kind of... even this doesn't change the situation:
> >
> > sTmp = Str@(pPoi
> > if i use
> > s=Str@(pPointer)
> >
> > this means
> > address1=adress2 ?
>
> Kind of... even this doesn't change the situation:
>
> sTmp = Str@(pPointer)
> s = sTmp
>
> I'm not sure this is good thing, may cause weird bugs and confusion!
> I think this is because strings are objects in Gamba
> if i use
> s=Str@(pPointer)
>
> this means
> address1=adress2 ?
>
Kind of... even this doesn't change the situation:
sTmp = Str@(pPointer)
s = sTmp
I'm not sure this is good thing, may cause weird bugs and confusion!
I think this is because strings are objects in Gambas...
maybe Str@() should
i made some examples in c++ and i get the same behavior when i free a
pointer the variable that holds its value is unusable.
ok, sorry i must study about pointers i think i mixed up some things in
the last post... sorry
On Mon, 2011-01-10 at 23:05 +0200, Demosthenes Koptsis wrote:
> On Mon, 2011-
On Mon, 2011-01-10 at 21:58 +0200, Jussi Lahtinen wrote:
> Oh, I forgot to mention, that when you do "Free(pPointer)", Gambas doesn't
> occupy that memory address for you anymore.
> And therefore some other process can write something to it, and result is
> not necessarily human readable.
>
> Juss
Oh, I forgot to mention, that when you do "Free(pPointer)", Gambas doesn't
occupy that memory address for you anymore.
And therefore some other process can write something to it, and result is
not necessarily human readable.
Jussi
On Mon, Jan 10, 2011 at 21:54, Jussi Lahtinen wrote:
>
>
>> firs
>
> first print gives the correct output
> /home/user/Documents/Development/Gambas3/Pointers7
>
> and the second after Free(pFunc) gives this
> �s&^...@^@^...@^@^...@^@^...@^@^...@ocuments/Development/Gambas3/Pointers7
>
This has something to do how strings are handled in Gambas, I don't think
th
i attach the Projects in case you want to see them.
On Mon, 2011-01-10 at 01:54 +0200, Demosthenes Koptsis wrote:
> so i manage to make it work...
>
> i saw an example that said to use PATH_MAX+1
> https://buildsecurityin.us-cert.gov/bsi/articles/knowledge/coding/760-BSI.html
>
> so i did
>
>
so i manage to make it work...
i saw an example that said to use PATH_MAX+1
https://buildsecurityin.us-cert.gov/bsi/articles/knowledge/coding/760-BSI.html
so i did
Example 1) --
' Gambas module file
'char *getcwd(char *buf, size_t size);
Extern getcwd(buf As Pointer, size As
1) Ok, i found why this function is dangerous.
https://buildsecurityin.us-cert.gov/bsi/articles/knowledge/coding/760-BSI.html
"Since the user cannot specify the length of the buffer passed to
getwd(), use of this function is discouraged. The length of a pathname
described in {PATH_MAX} is file syst
yes i read the man and i know that is suggested not to use this
function.
Although i just use it for demonstration for pointers.
That i didn't do is to check the header files.
The other thing is that i am total newbie to man 3 and i need some time
to get used to it, so please be patient.
i see
> so what can i do for
>
> char *getwd(char *buf);
>
> ?
>
You must know C programming first, and understand how getwd works. By typing
'man getwd', you will learn that you must not use that function, it is
dangerous and so deprecated.
Then you will read that buf must be a pointer to a memor
Although i get the working directory,
> > /mnt/store/LINUX/DOCUMENTS/DEVELOPMENT/Gambas/Προγραμματισμός σε
> > > Gambas/Το βιβλίο της Gambas3/Projects/Pointers86
but maybe the implementation of
char *getwd(char *buf);
is not correct i dont know!
On Sun, 2011-01-09 at 21:29 +0200, Demosthene
so what can i do for
char *getwd(char *buf);
?
On Sun, 2011-01-09 at 16:05 +0200, Jussi Lahtinen wrote:
> Hmmm. you cannot do alloc with size of string.
> Size of string is depended on length of string!
>
> Jussi
>
>
> On Sun, Jan 9, 2011 at 15:59, Demosthenes Koptsis
> wrote:
>
> > this
Hmmm. you cannot do alloc with size of string.
Size of string is depended on length of string!
Jussi
On Sun, Jan 9, 2011 at 15:59, Demosthenes Koptsis wrote:
> this example on pointers raises signal #6.
> Gambas3 svn3432 Ubuntu 10.04, AMD64
>
> ---
> ' Gambas module
this example on pointers raises signal #6.
Gambas3 svn3432 Ubuntu 10.04, AMD64
---
' Gambas module file
'char *getwd(char *buf);
Extern getwd(buf As Pointer) As Pointer In "libc:6"
Public Sub Main()
Dim pBuf As Pointer
Dim pFunc As Pointer
Dim sWorkingDirectory As S
26 matches
Mail list logo