ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/src/libstatgrab/process_stats.c
(Generate patch)

Comparing projects/libstatgrab/src/libstatgrab/process_stats.c (file contents):
Revision 1.52 by ats, Mon Apr 5 15:40:15 2004 UTC vs.
Revision 1.53 by ats, Mon Apr 5 18:10:11 2004 UTC

# Line 183 | Line 183 | sg_process_stats *sg_get_process_stats(int *entries){
183                  if(ptr !=NULL) *ptr='\0';
184  
185                  if (sg_update_string(&proc_state_ptr->process_name,
186 <                                  &ps_name[1]) == NULL) {
186 >                                     &ps_name[1]) < 0) {
187                          return NULL;
188                  }
189  
# Line 204 | Line 204 | sg_process_stats *sg_get_process_stats(int *entries){
204   #define READ_BLOCK_SIZE 128
205                  len = 0;
206                  do {
207 <                        if (VECTOR_RESIZE(psargs, len + READ_BLOCK_SIZE + 1) < 0) {
207 >                        if (VECTOR_RESIZE(psargs, len + READ_BLOCK_SIZE) < 0) {
208                                  return NULL;
209                          }
210                          rc = read(fn, psargs + len, READ_BLOCK_SIZE);
# Line 225 | Line 225 | sg_process_stats *sg_get_process_stats(int *entries){
225                          if (*ptr == '\0') *ptr = ' ';
226                          ptr++;
227                  }
228                /* for safety's sake */
229                psargs[len] = '\0';
228  
229 <                if (sg_update_string(&proc_state_ptr->proctitle, psargs) == NULL) {
229 >                if (len == 0) {
230 >                        /* We want psargs to be NULL. */
231 >                        if (VECTOR_RESIZE(psargs, 0) < 0) {
232 >                                return NULL;
233 >                        }
234 >                } else {
235 >                        /* Not empty, so append a \0. */
236 >                        if (VECTOR_RESIZE(psargs, len + 1) < 0) {
237 >                                return NULL;
238 >                        }
239 >                        psargs[len] = '\0';
240 >                }
241 >
242 >                if (sg_update_string(&proc_state_ptr->proctitle, psargs) < 0) {
243                          return NULL;
244                  }
245   #endif
# Line 278 | Line 289 | sg_process_stats *sg_get_process_stats(int *entries){
289   #else
290                  name = kp_stats[i].kp_proc.p_comm;
291   #endif
292 <                if (sg_update_string(&proc_state_ptr->process_name, name) == NULL) {
292 >                if (sg_update_string(&proc_state_ptr->process_name, name) < 0) {
293                          return NULL;
294                  }
295  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines