pike.git / src / post_modules / Shuffler / a_source_system_memory.c

version» Context lines:

pike.git/src/post_modules/Shuffler/a_source_system_memory.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id$ +    */      #include "global.h"   #include "bignum.h"   #include "object.h"   #include "interpret.h"      #include <shuffler.h>      
pike.git/src/post_modules/Shuffler/a_source_system_memory.c:17:    * Argument: An initialized instance of the System.Memory class    */   static struct program *shm_program = NULL;      struct sm_source   {    struct source s;       struct object *obj;    struct { -  unsigned char *data; +  char *data;    size_t len;    } *mem;       int offset, len;   };      static struct data get_data( struct source *src, off_t len )   {    struct sm_source *s = (struct sm_source *)src;    struct data res;
pike.git/src/post_modules/Shuffler/a_source_system_memory.c:61:      struct source *source_system_memory_make( struct svalue *s,    INT64 start, INT64 len )   {    struct sm_source *res;       if( TYPEOF(*s) != PIKE_T_OBJECT )    return 0;       if (!shm_program) { -  push_text("System.Memory"); +  push_static_text("System.Memory");    SAFE_APPLY_MASTER("resolv", 1);    shm_program = program_from_svalue(Pike_sp - 1);    if (!shm_program) {    pop_stack();    return 0;    }    add_ref(shm_program);    pop_stack();    }    -  res = malloc( sizeof( struct sm_source ) ); -  MEMSET( res, 0, sizeof( struct sm_source ) ); +  res = calloc( 1, sizeof( struct sm_source ) ); +  if( !res ) return NULL;    -  if( !(res->mem = (void*)get_storage( s->u.object, shm_program ) ) ) +  if( !(res->mem = get_storage( s->u.object, shm_program ) ) )    {    free(res);    return 0;    }       if( !res->mem->data || !res->mem->len )    {    free(res);    return 0;    }