void *ferite_classic_realloc( void *targetptr, size_t size, FeriteScript *script ) { #ifdef FERITE_MEM_DEBUG struct ferite_memory_block *ptr; #endif if( targetptr == NULL ) return ferite_classic_malloc( size, "ferite_mem.c", 125, script ); else { LOCK_MEMORY; ferite_classic_realloc_count++; #ifdef FERITE_MEM_DEBUG for( ptr = mem_rootblk; ptr->next != NULL; ptr = ptr->next ) { if( ptr->next->data == targetptr ) { ptr->next->data = rrealloc( ptr->next->data, size ); ptr->next->size = size; UNLOCK_MEMORY; return ptr->next->data; } } #endif targetptr = rrealloc( targetptr, size ); UNLOCK_MEMORY; return targetptr; } }
void * gzhandle::load(const char * p_dir, const char * p_file, t_length *p_lenght, t_length start_address, bool safe) { open(p_dir, p_file, "rb", safe); if(!f) return(NULL); if(start_address) seek(start_address, SEEK_SET); #define BUFFER_STEP 32768 char *p_buffer = NULL; t_length pos = 0; t_length ret; do { p_buffer = (char *)rrealloc(p_buffer, pos+BUFFER_STEP); ret = read(p_buffer+pos, BUFFER_STEP); pos += ret; } while(ret == BUFFER_STEP); *p_lenght = pos; return(p_buffer); }
static void push_stack(long val) { sp++; if (sp>stacksize) { stacksize+=10; stack=rrealloc(stack,stacksize*sizeof(long)); } stack[sp-1]=val; }
/* * Chains a RedditComment as a reply on another RedditComment. */ EXPORT_SYMBOL void redditCommentAddReply (RedditComment *comment, RedditComment *reply) { comment->replyCount++; RedditComment* ptr = comment; while (ptr != NULL) { ptr->totalReplyCount += reply->totalReplyCount + 1; ptr = ptr->parent; } comment->replies = rrealloc(comment->replies, (comment->replyCount) * sizeof(RedditComment*)); comment->replies[comment->replyCount - 1] = reply; reply->parent = comment; }
void mesh_vertex::array_position_add(int num) { int new_num = position_num+num; p_pos = (VECT **)rrealloc(p_pos,new_num*sizeof(p_pos[0])); int i; for(i = position_num; i < new_num; i++) p_pos[i] = (VECT *)mmalloc(sizeof(p_pos[0][0])*vertexnum); position_num = new_num; }
void mesh_vertex::array_text_add(int num) { int new_num = text_num+num; p_uv = (VECTUV **)rrealloc(p_uv,new_num*sizeof(p_uv[0])); int i; for(i = text_num; i < new_num; i++) p_uv[i] = (VECTUV *)mmalloc(sizeof(p_uv[0][0])*vertexnum); text_num = new_num; }
void mesh_vertex::array_spec_add(int num) { int new_num = specular_num+num; p_specular = (RGBF **)rrealloc(p_specular,new_num*sizeof(p_specular[0])); int i; for(i = specular_num; i < new_num; i++) p_specular[i] = (RGBF *)mmalloc(sizeof(p_specular[0][0])*vertexnum); specular_num = new_num; }
void mesh_vertex::array_diff_add(int num) { int new_num = diffuse_num+num; p_diffuse = (RGBAF **)rrealloc(p_diffuse,new_num*sizeof(p_diffuse[0])); int i; for(i = diffuse_num; i < new_num; i++) p_diffuse[i] = (RGBAF *)mmalloc(sizeof(p_diffuse[0][0])*vertexnum); diffuse_num = new_num; }
void mesh_vertex::array_normal_add(int num) { int new_num = normal_num+num; p_norm = (VECT **)rrealloc(p_norm,new_num*sizeof(p_norm[0])); int i; for(i = normal_num; i < new_num; i++) p_norm[i] = (VECT *)mmalloc(sizeof(p_norm[0][0])*vertexnum); normal_num = new_num; }
static long pop_stack(void) { long n; if (sp==0) { writeln("GAME ERROR: Stack underflow."); return 0; } n=stack[--sp]; if (sp+100<stacksize) { stacksize-=50; stack=rrealloc(stack,stacksize*sizeof(long)); } return n; }
static rbool push_subcall(int cnum, int ip, int failaddr) { subcall_rec *savestack; /* In case something goes wrong. */ if (MAX_SUBCALL!=0 && ++subcnt>MAX_SUBCALL) return 0; if (subcnt>subsize) { subsize+=5; savestack=substack; rm_trap=0; substack=rrealloc(substack,subsize*sizeof(subcall_rec)); rm_trap=1; if (substack==NULL) { /* out of memory */ substack=savestack; return 0; } } substack[subcnt-1].cnum=cnum; substack[subcnt-1].ip=ip; substack[subcnt-1].failaddr=failaddr; return 1; }
/* * Adds a RedditLink onto a RedditLinkList */ EXPORT_SYMBOL void redditLinkListAddLink (RedditLinkList *list, RedditLink *link) { list->linkCount++; list->links = rrealloc(list->links, list->linkCount * sizeof(RedditLink*)); list->links[list->linkCount - 1] = link; }