PR_ARENA_ALLOCATE(p, &arenaOpt->pool, my_size); if( (void *)NULL == p ) { PR_Unlock(arenaOpt->lock); nss_SetError(NSS_ERROR_NO_MEMORY); return (void *)NULL; }   h = (struct pointer_header *)p; h->arena = arenaOpt; h->size = size; rv = (void *)((char *)h + sizeof(struct pointer_header)); (void)nsslibc_memset(rv, 0, size);
rv = nss_zalloc_arena_locked(arenaOpt, size);
nss_ZAlloc(  NSSArena *arenaOpt,  PRUint32 size){  struct pointer_header *h;  PRUint32 my_size = size + sizeof(struct pointer_header);  if( my_size < sizeof(struct pointer_header) ) {    /* Wrapped */    nss_SetError(NSS_ERROR_NO_MEMORY);    return (void *)NULL;  }  if( (NSSArena *)NULL == arenaOpt ) {    /* Heap allocation, no locking required. */    h = (struct pointer_header *)PR_Calloc(1, my_size);    if( (struct pointer_header *)NULL == h ) {      nss_SetError(NSS_ERROR_NO_MEMORY);      return (void *)NULL;    }    h->arena = (NSSArena *)NULL;    h->size = size;    /* We used calloc: it's already zeroed */    return (void *)((char *)h + sizeof(struct pointer_header));  } else {    void *p;    void *rv;    /* Arena allocation */#ifdef NSSDEBUG    if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) {      return (void *)NULL;    }#endif /* NSSDEBUG */    PR_Lock(arenaOpt->lock);    if( (PRLock *)NULL == arenaOpt->lock ) {      /* Just got destroyed */      nss_SetError(NSS_ERROR_INVALID_ARENA);      return (void *)NULL;    }#ifdef ARENA_THREADMARK    if( (PRThread *)NULL != arenaOpt->marking_thread ) {      if( PR_GetCurrentThread() != arenaOpt->marking_thread ) {        nss_SetError(NSS_ERROR_ARENA_MARKED_BY_ANOTHER_THREAD);        PR_Unlock(arenaOpt->lock);        return (void *)NULL;      }    }#endif /* ARENA_THREADMARK */    PR_ARENA_ALLOCATE(p, &arenaOpt->pool, my_size);    if( (void *)NULL == p ) {      PR_Unlock(arenaOpt->lock);      nss_SetError(NSS_ERROR_NO_MEMORY);      return (void *)NULL;    }    /*      * Do this before we unlock.  This way if the user is using     * an arena in one thread while destroying it in another, he'll     * fault/FMR in his code, not ours.     */    h = (struct pointer_header *)p;    h->arena = arenaOpt;    h->size = size;    rv = (void *)((char *)h + sizeof(struct pointer_header));    (void)nsslibc_memset(rv, 0, size);    PR_Unlock(arenaOpt->lock);    return rv;  }  /*NOTREACHED*/}