Logo Search packages:      
Sourcecode: csound version File versions  Download package

PUBLIC int csoundDestroyGlobalVariable ( CSOUND *  csnd,
const char *  name 
)

Free memory allocated for "name" and remove "name" from the database. Return value is CSOUND_SUCCESS on success, or CSOUND_ERROR if the name is not defined.

Definition at line 969 of file namedins.c.

{
    GlobalVariableEntry_t *p, *prvp;
    unsigned char         h;

    /* check for a valid name */
    if (UNLIKELY(csoundQueryGlobalVariable(csnd, name) == (void*) NULL))
      return CSOUND_ERROR;
    /* calculate hash value */
    h = name_hash_2(csnd, name);
    /* search database (simple version, as the name will surely be found) */
    prvp = NULL;
    p = (GlobalVariableEntry_t*) (csnd->namedGlobals[(int) h]);
    while (sCmp(name, (char*) (p->name)) != 0) {
      prvp = p;
      p = (GlobalVariableEntry_t*) p->nxt;
    }
    if (prvp != NULL)
      prvp->nxt = (struct GlobalVariableEntry_s *) (p->nxt);
    else
      csnd->namedGlobals[(int) h] = (void*) (p->nxt);
    free((void*) p);
    /* done */
    return CSOUND_SUCCESS;
}


Generated by  Doxygen 1.6.0   Back to index