Ignore:
Timestamp:
Oct 24, 2006, 8:49:18 AM (14 years ago)
Author:
Bruno Cornec
Message:

Huge patch to introduce low level functions that will bw used everywhere (mr_free, mr_asprintf, ...)
Nearly linking now due to that.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/mondo/src/common/libmondo-fifo.c

    r808 r900  
    2828#include "mondostructures.h"
    2929#include "libmondo.h"
     30#include "mr_mem.h"
    3031
    3132/**
     
    8283    assert_string_is_neither_NULL_nor_zerolength(device);
    8384    assert(direction == 'w' || direction == 'r');
    84     asprintf(&sz_dir, "%c", direction);
     85    mr_asprintf(&sz_dir, "%c", direction);
    8586    wise_upper_limit = (am_I_in_disaster_recovery_mode()? 8 : 32);
    8687    wise_lower_limit = 1;       // wise_upper_limit/2 + 1;
     
    8889    for (bufsize = wise_upper_limit, res = -1;
    8990         res != 0 && bufsize >= wise_lower_limit; bufsize--) {
    90         asprintf(&tmp,
     91        mr_asprintf(&tmp,
    9192                 "dd if=/dev/zero bs=1024 count=16k 2> /dev/null | buffer -o /dev/null -s %ld -m %d%c",
    9293                 internal_tape_block_size, bufsize, 'm');
    9394        res = run_program_and_log_output(tmp, 2);
    94         paranoid_free(tmp);
     95        mr_free(tmp);
    9596    }
    9697    if (!res) {
    9798        bufsize++;
    98         asprintf(&tmp, _("Negotiated max buffer of %d MB "), bufsize);
     99        mr_asprintf(&tmp, _("Negotiated max buffer of %d MB "), bufsize);
    99100        log_to_screen(tmp);
    100         paranoid_free(tmp);
     101        mr_free(tmp);
    101102    } else {
    102103        bufsize = 0;
     
    111112    }
    112113    if (bufsize) {
    113         asprintf(&g_sz_call_to_buffer,
     114        mr_asprintf(&g_sz_call_to_buffer,
    114115                 "buffer -m %d%c -p%d -B -s%ld -%c %s 2>> %s", bufsize,
    115116                 'm', (direction == 'r') ? 20 : 75,
    116117                 internal_tape_block_size, keych, device, MONDO_LOGFILE);
    117118    } else {
    118         asprintf(&g_sz_call_to_buffer, "dd bs=%ld %cf=%s",
     119        mr_asprintf(&g_sz_call_to_buffer, "dd bs=%ld %cf=%s",
    119120                 internal_tape_block_size, keych, device);
    120121    }
    121122    log_msg(2, "Calling buffer --- command = '%s'", g_sz_call_to_buffer);
    122123    fres = popen(g_sz_call_to_buffer, sz_dir);
    123     paranoid_free(sz_dir);
     124    mr_free(sz_dir);
    124125    if (fres) {
    125126        log_msg(2, "Successfully opened ('%c') tape device %s", direction,
     
    130131    }
    131132    sleep(2);
    132     asprintf(&tmp, "ps %s | grep \"%s\"", ps_options, g_sz_call_to_buffer);
     133    mr_asprintf(&tmp, "ps %s | grep \"%s\"", ps_options, g_sz_call_to_buffer);
    133134    if (run_program_and_log_output(tmp, 2)) {
    134135        log_msg(2, "Warning - I think I failed to open tape, actually.");
    135136    }
    136     paranoid_free(tmp);
     137    mr_free(tmp);
    137138    g_tape_buffer_size_MB = bufsize;
    138     asprintf(&tmp, "ps %s | grep buffer | grep -v grep", ps_options);
     139    mr_asprintf(&tmp, "ps %s | grep buffer | grep -v grep", ps_options);
    139140    if (run_program_and_log_output(tmp, 1)) {
    140141        fres = NULL;
     
    143144        log_to_screen(_("Buffer successfully started."));
    144145    }
    145     paranoid_free(tmp);
     146    mr_free(tmp);
    146147    return (fres);
    147148}
     
    157158
    158159    sync();
    159     asprintf(&command,
     160    mr_asprintf(&command,
    160161            "ps %s | grep -F \"%s\" | grep -Fv grep | awk '{print $1;}' | grep -v PID | tr -s '\n' ' ' | awk '{ print $1; }'", ps_options,
    161162            g_sz_call_to_buffer);
    162     paranoid_free(g_sz_call_to_buffer);
     163    mr_free(g_sz_call_to_buffer);
    163164    log_msg(2, "kill_buffer() --- command = %s", command);
    164165
    165166    tmp = call_program_and_get_last_line_of_output(command);
    166     paranoid_free(command);
     167    mr_free(command);
    167168
    168     asprintf(&command, "kill %s", tmp);
     169    mr_asprintf(&command, "kill %s", tmp);
    169170    log_msg(2, "kill_buffer() --- command = %s", command);
    170171
     
    172173        run_program_and_log_output(command, TRUE);
    173174    }
    174     paranoid_free(tmp);
    175     paranoid_free(command);
     175    mr_free(tmp);
     176    mr_free(command);
    176177}
    177178
Note: See TracChangeset for help on using the changeset viewer.