Thankyou Ian for your responses.
Thanks,
Nitish
On Fri, 6 Mar 2020, 21:01 Ian Lance Taylor, wrote:
> On Fri, Mar 6, 2020 at 7:18 AM Nitish Saboo
> wrote:
> >
> > > 3) Why is 'fmt.Println(InitStruct)' printing the struct fields even
> after freeing the memory ? [b]
> >
> > Because that's how C
On Fri, Mar 6, 2020 at 7:18 AM Nitish Saboo wrote:
>
> > 3) Why is 'fmt.Println(InitStruct)' printing the struct fields even after
> > freeing the memory ? [b]
>
> Because that's how C works. C is not a memory safe language, and it
> doesn't become memory safe just because you make the calls fro
Hi Ian,
> 3) Why is 'fmt.Println(InitStruct)' printing the struct fields even after
freeing the memory ? [b]
Because that's how C works. C is not a memory safe language, and it
doesn't become memory safe just because you make the calls from Go.
1)You mean to say the dangling pointer will return
On Fri, Mar 6, 2020 at 4:25 AM Nitish Saboo wrote:
>
> So what did I do :
>
> main.go
>
>
> var InitStruct *C.struct_Foo;
>
> func InitializeEngine(pattern string, path string) {
> pattern_db := C.CString(pattern)
> module_path := C.CString(path)
> if InitStruct != nil{
> C.free(unsafe.Po
Hi Ian,
So what did I do :
main.go
var InitStruct *C.struct_Foo;
func InitializeEngine(pattern string, path string) {
pattern_db := C.CString(pattern)
module_path := C.CString(path)
if InitStruct != nil{
C.free(unsafe.Pointer(InitStruct))
}
InitStruct := (*C.Foo)(C.calloc(1, C.sizeof_s
On Wed, Mar 4, 2020 at 10:06 PM Nitish Saboo wrote:
>
> Thank you for the response.Got it.
> Basically, fmt.Println(InitStruct) is printing the values of fields, cb and
> data, for the struct Foo pointed by InitStruct.
> fmt.Printf("%p\n", InitStruct) is printing the memory address.
> Btw..can yo
Hi Ian,
Thank you for the response.Got it.
Basically, fmt.Println(InitStruct) is printing the values of fields, cb and
data, for the struct Foo pointed by InitStruct.
fmt.Printf("%p\n", InitStruct) is printing the memory address.
Btw..can you please clarify the following :
1)Is this the correct w
On Wed, Mar 4, 2020 at 3:57 AM Nitish Saboo wrote:
>
> I have CGO project.
>
> Following is my C header file and Go code
>
> syslog-node.h
> ===
>
> #ifndef _TEST_H_
> #define _TEST_H_
>
> #include
>
> typedef void (*key_value_cb)(const char* key, const char* value, size_t
> value_le