[Rd] Error registering finalizer

From: Paul Roebuck <roebuck_at_odin.mdacc.tmc.edu>
Date: Tue 26 Jul 2005 - 22:16:49 GMT


What exactly is a reference object? I'm getting this error message attempting to register a finalizer:

        can only weakly reference/finalize reference objects

I don't see any problem with the code... Here's what appears to be the relevant portions.

setClass("PDNNObject",

         representation(handle = "externalptr",
                        id     = "character",
                        "VIRTUAL"),
         prototype=list(handle = NULL))
setClass("ProbesetGE",
         representation("PDNNObject"))


static void ProbesetGE_finalizer(SEXP vntData) {

    Rprintf("In ProbesetGE_finalizer()\n");     /* Deallocate memory of structure fields */ }

static SEXP AllocateProbesetGEPtr(unsigned count) {

    return R_AllocatePtr(count,

                         sizeof(ProbesetGE_t),
                         ProbesetGETypeTag));
}

SEXP R_PDNN_newProbesetGE(unsigned count) {

    SEXP vntObj;
    SEXP vntClassDef;
    SEXP vntData;
    SEXP vntAttr;
    SEXP vntHandle;
    unsigned n = 0;

    PROTECT(vntClassDef = MAKE_CLASS(PROBESET_GE_CLASS_NAME)); n++;
    PROTECT(vntObj      = NEW_OBJECT(vntClassDef)); n++;
    PROTECT(vntHandle   = AllocateProbesetGEPtr(count)); n++;
    SET_SLOT(vntObj, HandleSlotSymbol, vntHandle);
    PROTECT(vntData = R_ExternalPtrProtected(vntHandle)); n++;
    PROTECT(vntAttr = NEW_INTEGER(1)); n++;
    INTEGER(vntAttr)[0] = count;

    SET_COUNT(vntData, vntAttr);

>>>>> Problem comes here <<<<<<

    R_RegisterCFinalizer(vntData, (R_CFinalizer_t)ProbesetGE_finalizer);

    UNPROTECT(n);

    return vntObj;
}

Thanks for any pointers...



SIGSIG -- signature too long (core dumped)

R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed Jul 27 08:20:16 2005

This archive was generated by hypermail 2.1.8 : Mon 20 Feb 2006 - 03:21:15 GMT