PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.ruby > Detaching free function from String in C API
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Detaching free function from String in C API

Réponse
 
LinkBack Outils de la discussion
Vieux 01/04/2008, 12h45   #1
Alex Fenton
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Detaching free function from String in C API

Hi

In a C extension, you can unset the 'free' function that will be called
when an object is garbage collected with something like:

RDATA(obj)->dfree = 0;

This is useful if you know that whatever C library you're interfacing to
will take care of free-ing the C structure.

Is the same thing is possible with an in-built ruby String object, to
set it so that the underlying char* contents will not be freed when the
String is GC'd?

thanks
alex
  Réponse avec citation
Vieux 01/04/2008, 13h02   #2
ts
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Detaching free function from String in C API

Alex Fenton wrote:
> Is the same thing is possible with an in-built ruby String object, to
> set it so that the underlying char* contents will not be freed when the
> String is GC'd?


Look at mmap (in RAA), when you write

m = Mmap.new("aa")

the object in `m' is in reality a String object and mmap make in
sort that ruby will never free the char * content, otherwise it
will crash.

Guy Decoux



  Réponse avec citation
Vieux 01/04/2008, 15h30   #3
Alex Fenton
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Detaching free function from String in C API

ts wrote:
> Alex Fenton wrote:
>> Is the same thing is possible with an in-built ruby String object, to
>> set it so that the underlying char* contents will not be freed when the
>> String is GC'd?

>
> Look at mmap (in RAA), when you write
>
> m = Mmap.new("aa")
>
> the object in `m' is in reality a String object and mmap make in
> sort that ruby will never free the char * content, otherwise it
> will crash.


Perfect, thanks. I will read the source and ponder

alex
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 02h45.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,09506 seconds with 11 queries